fix: don't auto-approve PRs that change the bot's own guardrails - #758
Merged
Conversation
Add a check that skips auto-approval when a PR modifies .github/** or .shadow.yml. Without it, a PR that weakens the approval gate (or repoints the bot at a different engine) is approved by the very gate it edits. Paginates listFiles so a large PR cannot slip a guarded file past a 30-item page.
sudsali
marked this pull request as ready for review
July 6, 2026 19:39
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.
Summary
Hardens
auto-approve.ymlso the bot never auto-approves a PR that modifies its own guardrails.The gap
auto-approve.ymlapproves any PR where the bot posted a clean review + CI passed. It has no check on what the PR changes — so a PR that editsauto-approve.ymlitself (weakening the gate), or.shadow.yml/ a workflow (e.g. repointing the bot at a different engine SHA), gets auto-approved by the very gate it modifies. GitHub branch protection still requires a human to merge, but auto-approval of self-modifying PRs shouldn't happen.The fix
A "Condition 0" check runs before the CI/marker conditions: it lists the PR's changed files (paginated, so a large PR can't slip a guarded file past a single page) and skips auto-approval if any path is under
.github/or is.shadow.yml. Those PRs require a human approval. Normal source/test PRs are unaffected.Rollback
Revert this PR — the Condition 0 block is removed and behavior returns to CI + clean-marker only.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.