Repository navigation
fix(hooks): improve local main branch guard issue1198 - #1204
Conversation
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1204/ The preview will be removed when this PR is closed. |
|
loop review probe |
LOOP_VERDICT_V2verdict: APPROVE
|
|
post-merge-cleanup report draft |
|
post-merge-cleanup: ok (status ok) |
post-merge-cleanup: 完了 (2026-06-27T06:35:00Z)
|
|
POST_MERGE_CLEANUP_REPORT_V1: {status: ok, generated_at: "2026-06-27T06:35:00Z", generated_by: post-merge-cleanup-worker, human_review_required: false, cleaned_branches: [], cleaned_worktrees: [], unresolved_cleanup_items: [], parent_issue_status: {parent_issue_number: null, all_children_closed: true, recommended_action: n/a}, superseded_prs: [], follow_up_issue_requests: [], stash_restored: n/a, stash_entry_ref: null, warnings: [], errors: []} |
you askedmessage time: 2026-06-27 15:14:35 #1204 chatgpt responsePR本体だけでなく、関連Issue/PR・差分・既存設計文書・CI/コメントを突き合わせます。実装が依存する技術仕様は公開情報で確認し、最後に「マージ阻害」「仕様破綻」「改善Issue候補」に分けてレビューします。 現在のPR head は 差分上の主要な危険点は2つ見えています。1つは実hookのstderr diagnosticsがACの構造化診断に追いついていない点、もう1つは 判定: REQUEST_CHANGESPR #1204 は現 head 良い点
ブロッカーB1. AC7 の “hook failure diagnostics” は実hookでは満たしていない
さらに、追加テストの多くは 修正要求: block stderr に bounded な構造化診断を出す。raw command 全文は出さず、例えば以下のキーだけを最大10行内に出す。 B2.
|
| 判断 | 推奨 |
|---|---|
| main を Claude/Codex/rtk がすぐ参照する | Revert |
| safety hook / guardrail の緩和・誤分類が疑われる | Revert |
| CI green だが仕様AC未達 | Revert or hotfix、今回はRevert寄り |
| 実行中ユーザー影響がない普通のUI修正 | hotfixでも可 |
git revert は破壊的な履歴改変ではなく、戻すコミットを追加するだけなので、GitHub運用上は安全です。reset / force push は不要です。
AIに投げる指示: Revert + #1198 reopen
このまま Claude Code / Codex CLI に渡してください。
**Standard Title: **
目的:
誤って merged した PR #1204 を安全に revert し、Issue #1198 を未完了として reopen または post-merge remediation Issue に接続する。main の履歴改変・force push は禁止。通常の revert commit + PR で戻す。
背景:
PR #1204 は fix(hooks): improve local main branch guard issue1198 で、Issue #1198 を Closes 1198 として merged された。しかしレビューで以下の未達が判明している。
- AC7: 実 hook failure stderr に
hook_name / event_kind / decision / reason_code / rule_id / command_kind / parser_stage / argv_redactedが出ていない gh apiparser が--raw-field=.../--field=.../--input=.../-Xなど公式 flag grammar に対して不十分unknown_command_requires_reviewが status=allow と併用され、reason vocabulary が矛盾しているdocs/dev/hook-boundaries.mdが新 reason_code /gh api/rtk wrapperと同期していない- schema compatibility test が exact keyset から subset check に緩められ、契約退行を隠す
- raw fixture の実 hook script 経由検証が不足している
実施手順:
- 最新 main を取得する。
- PR fix(hooks): improve local main branch guard issue1198 #1204 の merge commit
423d5cec8955476257bff3b3b02e1ae7059a9fc4を確認する。 - merge commit が2親なら
git revert -m 1 423d5cec8955476257bff3b3b02e1ae7059a9fc4、1親ならgit revert 423d5cec8955476257bff3b3b02e1ae7059a9fc4を使う。必ず親数を確認してから実行する。 - revert 用ブランチを作成し、root checkout を不用意に main 以外へ drift させない。既存の worktree 運用・guardrail に従う。
- revert PR を作成する。タイトルは
revert: PR #1204 local_main_branch_guard incomplete remediation。 - PR本文に以下を明記する。
- Reverts fix(hooks): improve local main branch guard issue1198 #1204
- 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 は未達ACが残っているため completed ではない
- main には安全ガードの不完全変更を残さない
- 後続で 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 または remediation Issue にて修正版を実装する
- 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 が closed なら reopen する。reopen できない場合は、実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 / fix(hooks): improve local main branch guard issue1198 #1204 / revert PR を参照する追加修正Issueを起票する。
- CIを確認し、revert PRが green になるまで修正する。
禁止:
- main への force push / reset
- secret / token / credential の表示
- GitHub API blanket allow の追加
gh issue edit/gh apiの書き込み許可条件の緩和- root checkout を default branch 以外へ drift させる操作
- 人間承認なしの破壊的操作
停止条件:
- revert が conflict し、手動判断なしでは安全に解消できない
- allowed paths 外の変更が必要
- secret / credential / private token が関係する
- 権限不足で 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 reopen または PR作成ができない
追加修正Issueを起票する場合の草案
#1198 を reopen できるなら、それが第一候補です。新規Issueを作るなら、タイトルと本文はこれでよいです。
**Document Title: **
fix(hooks): complete post-merge remediation for PR #1204 / Issue #1198
Background
PR #1204 was merged as an implementation of Issue #1198, but post-merge review found that several Issue #1198 acceptance criteria remain incomplete. Because this code changes local AI hook guardrails, incomplete classifier / diagnostics behavior should not be treated as completed.
Problem
The merged implementation improves parts of local_main_branch_guard, but leaves the following gaps:
- Runtime hook failure diagnostics are not emitted through the real hook stderr path.
gh apiparser does not explicitly deny the full mutation/file-read flag grammar such as--raw-field=...,--field=...,--input=..., and-X.unknown_command_requires_reviewis used withstatus=allow, creating policy/telemetry ambiguity.docs/dev/hook-boundaries.mdis not synchronized with new reason codes and command kinds.- schema compatibility tests were relaxed from exact keyset to subset matching.
- raw hook event fixtures are not sufficiently verified through the actual hook script path.
rtkwrapper regression coverage is too thin for branch mutation and destructive GitHub operations.
Scope
- Complete the missing 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 acceptance criteria.
- Preserve local root default branch protection.
- Preserve existing GitHub remote write policy.
- Do not add blanket
gh apiallow. - Treat
rtkas a monitored wrapper envelope, not as a bypass. - Keep diagnostics bounded and redacted.
Acceptance Criteria
- Block stderr from the actual hook path includes bounded diagnostic fields:
hook_nameevent_kinddecisionreason_coderule_idcommand_kindparser_stageargv_redacted
-
gh apiexact GET issue-comment endpoint remains allowed. -
gh apiwith--raw-field,--field,-f,-F,--input,-X POST|PATCH|PUT|DELETE,--method POST|PATCH|PUT|DELETE, orgraphqlis blocked or review-required with distinct diagnostics. -
rtk gh api ...follows the samegh apiclassifier result as the unwrapped command. -
rtk git switch,rtk git checkout -b,rtk git branch -M,rtk gh pr checkout, andrtk gh pr merge --delete-branchare blocked. -
unknown_command_requires_reviewis not returned withstatus=allow; either block/review it or rename the allow case to a non-review reason code. -
docs/dev/hook-boundaries.mdlists all new reason codes and classifier categories. - schema compatibility tests assert the exact intended keyset or explicitly migrate to a new schema version.
- PreToolUse / PermissionRequest / Stop raw fixtures are tested through the actual hook script path, not only
evaluate()direct calls. -
pnpm typecheck,pnpm lint,pnpm test,pnpm build, and relevant Python hook tests pass.
Verification Commands
pnpm typecheck
pnpm lint
pnpm test
pnpm build
uv run pytest tests/codex/test_local_main_branch_guard.py -q
uv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -q
uv run python3 scripts/check_hook_boundaries.py
uv run python3 scripts/check_codex_agent_config.py --assert-local-main-branch-guardReferences
- Issue 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198
- PR fix(hooks): improve local main branch guard issue1198 #1204
- Revert PR for fix(hooks): improve local main branch guard issue1198 #1204, if created
その後の修正版AI指示
Revert後に改めて修正させるなら、次の短い指示で十分です。
**Standard Title: **
Issue #1198 を再実装してください。PR #1204 は未達ACがあるため revert 済み、または revert PR と並行して修正します。
必須:
- 実装: local hook の unparseable_branch_mutation 誤判定で issue-refinement-loop が停止する問題を解消する #1198 のACを再確認し、未達だった AC7 / AC3 / AC10 / AC11 / AC12 / AC15 / AC16 を重点的に満たす
gh apiは exact GET issue-comment endpoint のみ allow--raw-field=.../--field=.../--input=.../-X/ mutation method / graphql は明示 blockrtkは bypass allow しない。unwrap して inner command を既存 classifier に委譲する- actual hook script path で PreToolUse / PermissionRequest / Stop raw fixture を検証する
- block stderr に bounded redacted diagnostics を出す
- unknown command の allow/review/block vocabulary を矛盾なく整理する
- docs/dev/hook-boundaries.md と tests を同期する
- schema keyset を subset check で逃がさない
禁止:
- GitHub remote write policy の拡張
gh apiblanket allowgh issue editの--repo squne121/loop-protocol + --body-file tmp/...条件緩和- local root default branch protection の緩和
- force push / reset
完了条件:
- PR本文に
Closes #1198または該当 follow-up Issue を記載 - すべての関連CI green
- レビュー指摘の各項目に対して、対応ファイル・テスト名・検証コマンドをPR本文に明記
最短で安全に進めるなら、まず revert PR、次に #1198 reopen、最後に 修正版PR です。
Summary\nこのPRはIssue 1198の実装です。\nCloses 1198