Repository navigation
feat: implement issue #1281 — pr-review mention listener: send force_review=true for a trusted human comment mention, so the documented @donpetry-bot break-glass works again #1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c577699
feat: implement issue #1281 — pr-review mention listener: send force_…
don-petry c7147b4
fix(reviews): assert status in bats, reject [bot] authors, make tooli…
don-petry 115f080
fix(reviews): use test-scoped path for injection canary in force-revi…
don-petry bcd31f7
fix(bot): add missing status assertion in force-review bats test
don-petry 766aa15
fix(bot): use bash [[ ]] consistently in conditional on line 60
don-petry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/usr/bin/env bash | ||
| # force_review decision for the pr-review-mention reusable workflow (#1281). | ||
| # | ||
| # Pure and side-effect-free, so it can be unit-tested with bats (see | ||
| # test/workflows/pr-review-mention/force-review.bats). The reusable sources this | ||
| # file from its own commit and acts on the verdict in "Trigger review agent". | ||
| # | ||
| # pr-review.yml in .github-private sets FORCE_REVIEW (skip the advisory-bot and | ||
| # comment-disposition waiting gates; the review itself still runs in full) only | ||
| # when the dispatch carries client_payload.force_review == true. The rule: | ||
| # - a trusted human's @donpetry-bot comment (OWNER / MEMBER / COLLABORATOR, | ||
| # not donpetry-bot, no automation marker) is the break-glass → force; | ||
| # - the review_requested path never forces; | ||
| # - a comment carrying an automation marker never forces. Agents post as the | ||
| # owner account, so the association alone cannot tell them from a person. | ||
| # Known, accepted limit: an agent posting as the owner WITHOUT a marker is | ||
| # indistinguishable from the maintainer and is forced too. | ||
|
|
||
| # Body substrings that identify an agent-posted comment. | ||
| PR_REVIEW_MENTION_AUTOMATION_MARKERS=( | ||
| '<!-- pr-review-agent' | ||
| '<!-- pr-review-claim' | ||
| '<!-- persona:' | ||
| '<!-- dev-lead' | ||
| '<!-- dependency-advisory' | ||
| '<!-- maintainer-resolve' | ||
| '<!-- auto-rebase-conflict' | ||
| ) | ||
|
|
||
| # pr_review_mention_force_decision EVENT_NAME AUTHOR_ASSOC AUTHOR_LOGIN BODY | ||
| # Prints one line "<verdict> <rule>" and returns 0. Verdicts: | ||
| # force dispatch with client_payload[force_review]=true | ||
| # plain dispatch without the flag (today's behaviour) | ||
| # none do not dispatch (untrusted / bot author / unsupported event) | ||
| # AUTHOR_ASSOC, AUTHOR_LOGIN and BODY are the comment's fields; they are | ||
| # ignored for the pull_request (review_requested) event. | ||
| pr_review_mention_force_decision() { | ||
| local event="$1" assoc="$2" login="$3" body="$4" marker | ||
|
|
||
| case "$event" in | ||
| pull_request) | ||
| echo "plain review-requested" | ||
| return 0 | ||
| ;; | ||
| issue_comment | pull_request_review_comment) ;; | ||
| *) | ||
| echo "none unsupported-event" | ||
| return 0 | ||
| ;; | ||
| esac | ||
|
|
||
| case "$assoc" in | ||
| OWNER | MEMBER | COLLABORATOR) ;; | ||
| *) | ||
| echo "none untrusted-association" | ||
| return 0 | ||
| ;; | ||
| esac | ||
|
|
||
| if [[ "$login" == "donpetry-bot" || "$login" == *"[bot]" ]]; then | ||
| echo "none bot-author" | ||
| return 0 | ||
| fi | ||
|
|
||
| for marker in "${PR_REVIEW_MENTION_AUTOMATION_MARKERS[@]}"; do | ||
| if [[ "$body" == *"$marker"* ]]; then | ||
| echo "plain automation-marker" | ||
| return 0 | ||
| fi | ||
| done | ||
|
|
||
| echo "force trusted-human-comment-mention" | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.