Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "main ブランチへの直接 push を GitHub 側の branch protection / ruleset で防止する"
change_kind: workflow親 Issue
なし
目的
2026-05-24 に発生した main 直接 push インシデントの再発を、GitHub 側の保護設定で技術的に防ぐ。
PR #358 で main の復旧は完了済みであり、PR #355 で #324 の正規修正も merge 済み。ただし、main branch への直接 push を GitHub remote 側で拒否する保護設定が未完了であるため、本 Issue で main の branch protection / ruleset を hardening する。
現在の検証済みスコープ
- GitHub repository settings の
mainbranch protection / ruleset 設定 docs/ops/branch-protection.mdへの検証手順・設定 snapshot の記録
残存する Parent Gap
なし
成果
main branch への直接 push が GitHub remote 側で拒否される。
git push origin HEAD:main、git push origin <branch>:main、force push などの local bypass 試行に対しても、GitHub 側の設定により main 更新が成立しない。
実装方針
優先順位:
- GitHub Ruleset で
mainを対象に active enforcement を設定する - Ruleset が利用不可、または権限・プラン制約で困難な場合のみ Branch protection rule で代替する
In Scope
mainbranch を対象に以下を設定する:- Pull request before merge を必須化
- Required status checks を必須化:
typechecklinttestbuildpython-test
- Conversation resolution を必須化
- Force push を禁止
- Deletion を禁止
- Admin / bypass actor による bypass を禁止、または bypass actor を空にする
- 設定後に
git push origin HEAD:mainが remote 側で拒否されることを確認する - 有効な設定・検証手順・確認結果を
docs/ops/branch-protection.mdに記録する
Out of Scope
- SubAgent 側の push destination guard hook 実装(feat: implementation-worker SubAgent に push destination guard hook を追加する #360 で扱う)
- merge queue 導入
- release / staging 等の他 branch protection
- CI workflow 自体の変更
- GitHub Actions 権限モデルの全面見直し
Acceptance Criteria
- AC1:
mainを対象にした active ruleset、または branch protection rule が存在する - AC2:
mainへの commit は PR 経由必須で、直接 push では更新できない - AC3: required status checks に
typecheck,lint,test,build,python-testが含まれる - AC4: PR conversation resolution が必須化されている
- AC5: admin / bypass actor による bypass が許可されていない、または bypass actor が空である
- AC6:
git push origin HEAD:mainが GitHub remote 側で拒否されることを実測している - AC7:
docs/ops/branch-protection.mdに設定 snapshot と検証手順が記録されている
Verification Commands
# Branch protection fallback を使った場合
gh api repos/squne121/loop-protocol/branches/main/protection \
--jq '{
required_pull_request_reviews,
required_status_checks,
required_conversation_resolution,
enforce_admins,
restrictions,
allow_force_pushes,
allow_deletions
}'
# Ruleset を使った場合
gh api repos/squne121/loop-protocol/rules/branches/main --jq '.'
# 直接 push 拒否の実測
git checkout -b test-direct-push-main-protection
git commit --allow-empty -m "test: verify main direct push protection"
git push origin HEAD:main
# 期待: remote rejected / protected branch / ruleset violation / permission denied 系のエラーで失敗
# docs snapshot の存在確認
test -f docs/ops/branch-protection.md && echo "docs created"Allowed Operations
- GitHub repository settings:
- Rulesets for
main - Branch protection for
main
- Rulesets for
Allowed Paths
docs/ops/branch-protection.md
Stop Conditions
- GitHub UI / API で設定する権限が不足している
- GitHub plan / repository type の制約により必要な保護設定が使えない
- Required status check 名が GitHub UI/API 上で確定できない
main直接 push の拒否を実測できない- feat: implementation-worker SubAgent に push destination guard hook を追加する #360 の SubAgent hook 実装と責務が混線し始めた
.github/workflows/ci.yml変更が必要になった- 実装時間が手動 ops 作業として 2 時間を超過した
Required Skills
なし
Scope Delta
N/A
Background
2026-05-24 に implementation-worker SubAgent(Claude Haiku)が PR branch に push すべき修正 commit (abbc61a) を誤って main へ直接 push した。PR #358 で main の復旧は完了し、PR #355 で #324 の正規修正も merge 済み。ただし、main 直接 push を GitHub 側で技術的に拒否する設定は未完了であるため、本 Issue で branch protection / ruleset を hardening する。
根本原因の一つは、main branch に branch protection / ruleset が設定されておらず、GitHub API レベルで直接 push が成立していたこと。本 Issue は GitHub 側の hardening により、SubAgent / 人間のいずれの誤操作からも main 直接 push を技術的に不可能にすることを目的とする。
References
- Revert "fix(#324): refresh session-recording-policy table + warning per PR #355 review" #358 — main 直接 push インシデントの復旧 PR (MERGED)
- feat(#324): integrate session_recording_policy checker into CI and pnpm scripts #355 — 実装: session_recording_policy checker を CI / python-test workflow に統合する #324 の正規実装 PR (MERGED)
- 実装: session_recording_policy checker を CI / python-test workflow に統合する #324 — session_recording_policy checker の CI 統合 (CLOSED/COMPLETED)
- feat: implementation-worker SubAgent に push destination guard hook を追加する #360 — SubAgent 側の PreToolUse push destination guard (OPEN)
- インシデントコメント: Revert "fix(#324): refresh session-recording-policy table + warning per PR #355 review" #358 (comment)
- GitHub Docs: About protected branches
- GitHub Docs: About rulesets
- GitHub REST API: Rules
Activity
squne121 commentedon May 24, 2026
人間からの指摘です。
Issue 本文は日本語にしてほしい。
squne121 commentedon May 24, 2026
([Gmail]1)([Gmail]2)([Gmail]3)([Gmail]4)([Gmail]5)
判定: REQUEST_CHANGES
#359 の方向性は正しいですが、現状のまま実装Issueとして流すのは危険です。最大の問題は、本文が英語主体で、読者・実行者が日本語運用しているリポジトリの実装契約として不適合な点です。人間コメントでも「Issue 本文は日本語にしてほしい」と明示されています。これは単なる文体修正ではなく、実行契約の読み違いを防ぐための blocker と扱うべきです。
#359 は PR #358 の復旧後 follow-up として妥当です。PR #358 は
abbc61aの main 直接pushを revert する復旧PRで、本文でも #359 と #360 を再発防止Issueとして分離しています。さらに PR #355 は既に merged で、#324 も completed なので、#359 の背景文にある “Recovery PR #358 is currently addressing the incident” は古くなっています。Blocker 1: Issue本文を日本語化する
現在の #359 は見出し・Outcome・In Scope・Acceptance Criteria・Stop Conditions が英語主体です。
loop-protocolの最近の Issue / PR は日本語運用の比重が高く、#324 のような契約Issueも日本語で詳細化されています。#359 は人間・SubAgent・reviewer が直接読む安全設定Issueなので、日本語で誤読余地を減らすべきです。修正要求: #359 本文を日本語契約に差し替え、英語は
Machine-Readable Contractの値や必要な GitHub 設定名だけに限定してください。Blocker 2: 背景が stale
#359 本文は「PR #358 is currently addressing the incident」と書いていますが、取得時点で PR #358 は closed / merged です。PR #355 も merged 済みです。したがって、背景は「復旧中」ではなく「復旧済み、ただし再発防止未完了」に更新する必要があります。
修正要求: Background を次の意味に更新してください。
Blocker 3: #360 への参照が古い
#359 の Out of Scope は「SubAgent-side push destination guard は別Issue、作成後にリンク」となっていますが、#360 は既に作成済みです。#360 は PreToolUse hook で
git pushの main/master 宛てを exit 2 で止める補完策なので、#359 から明示リンクすべきです。修正要求: #359 の Out of Scope / References に
#360を直接入れてください。Blocker 4: 「branch protection or ruleset」が曖昧すぎる
GitHub の branch protection は「PR必須」「status checks必須」「conversation resolution必須」「bypass禁止」「push制限」を設定できます。特に admin / bypass 権限者には既定では保護が適用されないため、
Do not allow bypassing the above settings相当を明示するのは正しいです。([GitHub Docs]6)一方で、rulesets は branch protection と併用でき、複数 ruleset が同時適用されるため、今後の拡張性は rulesets の方が高いです。GitHub Docs でも rulesets は既存の branch protection と並行して動作し、複数 ruleset の rule は集約され、より厳しい方が適用されると説明されています。([GitHub Docs]7)
修正要求: 「branch protection or ruleset」ではなく、優先実装を明示してください。推奨は ruleset 優先、branch protection は fallback です。
Blocker 5: AC が不足している
現在の AC は大枠としては良いですが、「何を設定できたら pass か」が弱いです。GitHub rulesets の REST API では、
pull_requestrule は「target branch 以外に commit し、PR 経由で merge すること」を要求でき、required_review_thread_resolutionも pull request rule の parameter として表現できます。required_status_checksは ref 更新前に指定 status check が pass していることを要求します。([GitHub Docs]8) ([GitHub Docs]8)現在の CI job 名は
typecheck,lint,test,build,python-testで一意です。GitHub Docs は required status checks を使う場合、workflow 間で job name が重複すると PR merge が block され得ると注意しているため、この5つを required checks として固定するのは妥当です。 ([GitHub Docs]6)修正要求: AC を次の水準まで具体化してください。
Non-blocking:
Allowed Pathsが実態とズレているGitHub UI で ruleset / branch protection を設定する場合、通常は repository file path の変更ではありません。現在の
Allowed Pathsに.github/が含まれていますが、今回の主成果物は GitHub repository setting であって.github/ではありません。.github/を許可すると、workflow や settings を無関係に触る逃げ道になります。修正案:
差し替え用の日本語 Issue 本文案
親 Issue
なし
目的
2026-05-24 に発生した main 直接 push インシデントの再発を、GitHub 側の保護設定で技術的に防ぐ。
PR #358 で main の復旧は完了済みであり、PR #355 で #324 の正規修正も merge 済み。ただし、main branch への直接 push を GitHub remote 側で拒否する保護設定が未完了であるため、本 Issue で
mainの branch protection / ruleset を hardening する。現在の検証済みスコープ
mainbranch protection / ruleset 設定docs/ops/branch-protection.mdへの検証手順・設定 snapshot の記録成果
mainbranch への直接 push が GitHub remote 側で拒否される。git push origin HEAD:main、git push origin <branch>:main、force push などの local bypass 試行に対しても、GitHub 側の設定により main 更新が成立しない。実装方針
優先順位:
mainを対象に active enforcement を設定するIn Scope
mainbranch を対象に以下を設定する:Pull request before merge を必須化
Required status checks を必須化
typechecklinttestbuildpython-testConversation resolution を必須化
Force push を禁止
Deletion を禁止
Admin / bypass actor による bypass を禁止、または bypass actor を空にする
設定後に
git push origin HEAD:mainが remote 側で拒否されることを確認する有効な設定・検証手順・確認結果を
docs/ops/branch-protection.mdに記録するOut of Scope
Acceptance Criteria
mainを対象にした active ruleset、または branch protection rule が存在するmainへの commit は PR 経由必須で、直接 push では更新できないtypecheck,lint,test,build,python-testが含まれるgit push origin HEAD:mainが GitHub remote 側で拒否されることを実測しているdocs/ops/branch-protection.mdに設定 snapshot と検証手順が記録されているVerification Commands
Allowed Operations
GitHub repository settings:
mainmainAllowed Paths
docs/ops/branch-protection.mdStop Conditions
main直接 push の拒否を実測できない.github/workflows/ci.yml変更が必要になったRequired Skills
なし
関連
[-]ops: main branch protection / ruleset hardening to prevent direct push[/-][+]ops: main 直接 push 防止のための GitHub branch protection / ruleset hardening[/+]squne121 commentedon May 24, 2026
issue-refinement-loop: 完了 (2026-05-24)
事実確認結果(codebase-investigator 経由・main thread 検証)
typecheck/lint/test/build/python-test.github/workflows/ci.ymljobs と完全一致外部仕様 claim(GitHub Docs: rulesets / branch protection)は非 critical(推奨方針の裏付け)として参照扱い。
反映した修正(anchor comment の 5 blocker)
Allowed Pathsから.github/を除去しAllowed Operationsに分離(GitHub UI 設定が主成果物のため)追加調整
ops: main branch protection / ruleset hardening to prevent direct push→ops: main 直接 push 防止のための GitHub branch protection / ruleset hardeningtriage-requiredラベルを除去(refinement 完了により triage 不要)次アクション
issue-contract-reviewskill で baseline VC preflight を実行し、go判定後に手動 ops 実装へ進む。squne121 commentedon May 24, 2026
impl-review-loop: 完了 (APPROVE, マージ判断待ち)
モデル分担
16796903) 作成 / Branch protection 更新 (enforce_admins: true,python-test追加) /git push origin HEAD:main拒否実測 /docs/ops/branch-protection.md起草 / PR 起票 / PR 最終判定(Sonnet limit のため pr-reviewer SubAgent 不可、user 指示に従い Opus 直接判定)test-runner) / PR review evidence 収集 (general-purpose)Out-of-band 変更(GitHub side、git diff には現れない)
main-direct-push-protection16796903bypass_actors: [],current_user_can_bypass: never/branches/main/protectionenforce_admins: true, required checks:typecheck/lint/test/build/python-testAC 充足
AC1-AC7 すべて pass。詳細は PR #362 の APPROVE コメント参照。
マージ判断待ち
PR #362 は draft / CLEAN / MERGEABLE / CI 全 success。人間判断で ready-for-review に切り替えてマージするか、追加レビューを依頼するか決定してください。
docs(#359): address PR #362 review blockers — add raw snapshots + sou…
docs(#359): main branch protection / ruleset hardening (#362)