fix(bootstrap): stop applying classic branch protection - #349
Open
jdfalk wants to merge 1 commit into
Open
Conversation
falkcorp manages branch rules with org-wide rulesets. The bootstrap-repo skill was also installing per-repo classic protection, which is actively harmful: 1. Classic protection has no bypass_actors list. Org rulesets can exempt automation; classic protection cannot exempt anyone. It blocked the Sync from Template bot from pushing to main in 15 gha-* repos for ~4 months with GH006 "Changes must be made through a pull request". Adding bypass actors to the org rulesets did nothing, because classic protection does not consult them. 2. discover_status_checks.py collected job IDs, but GitHub reports status checks by display name. Required contexts like test-with-config never matched the reported Test With Valid Config, so they sat "Expected" forever and every PR was blocked. 34 Dependabot PRs were unmergeable. 3. Autodiscovery swept up set-auto-merge, whose job is gated on if: contains(labels, 'auto-merge'). Unlabelled PRs skip it, and a skipped required check never satisfies protection. Deleted apply_branch_protection.sh and discover_status_checks.py, dropped --skip-protection, and inverted verify_bootstrap.sh so the presence of classic protection is reported as drift. Also fixes a latent bug in that check: it tested gh api's output instead of its exit status, but gh api prints HTTP error bodies to stdout, so a 404 yielded a non-empty string and the absent case was undetectable. Verified both branches against real repos, with and without protection. Removed the dead --repo-path argument from verify_bootstrap.sh and both of its call sites; it existed only to feed discover_status_checks.py. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UsssaXSKwYAeEcV218SsnS
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.
Why
falkcorpmanages branch rules with org-wide rulesets. Thebootstrap-reposkill was also installing per-repo classic branch protection, which is actively harmful:Classic protection has no
bypass_actorslist. Rulesets can exempt automation; classic protection can exempt no one. It blocked theSync from Templatebot from pushing tomainin 15gha-*repos for ~4 months:Adding bypass actors to the org rulesets did nothing — classic protection does not consult them. Deleting it fixed the sync on the next run.
The required contexts could never be satisfied.
discover_status_checks.pycollected job IDs, but GitHub reports checks by display name:test-with-configTest With Valid ConfigvalidateValidate ActionThose contexts sat
Expectedforever, so every PR was blocked — 34 Dependabot PRs unmergeable, some for 6+ months.Conditional jobs became required checks.
set-auto-mergeis gated onif: contains(labels, 'auto-merge'). Unlabelled PRs skip it, and a skipped required check never satisfies protection. Theauto-mergelabel did not exist in any repo.What changed
apply_branch_protection.shanddiscover_status_checks.py--skip-protectionfrombootstrap_repo.shverify_bootstrap.sh: the presence of classic protection is now reported as drift, with the removal command--repo-patharg fromverify_bootstrap.shand both call sites (it existed only to feeddiscover_status_checks.py)references/branch-protection.mdas a do-not-do-this rationaleLatent bug also fixed
The old check did
PROTECTION=$(gh api ... || echo "")then tested-z.gh apiprints HTTP error bodies to stdout, so a 404 still yields a non-empty string — the "no protection" case was undetectable. Now tests the exit status.Verification
bash -n+shellcheck -S warningclean on all scriptsshfmtreformatting:✓ No classic branch protection✗ classic branch protection is present, then removed againRollout already applied
Classic protection removed from all 45
falkcorprepos (0 remain); configs backed up. The template-sync bot pushed successfully for the first time since 2026-04-25.