Skip to content

fix: repository-wide の stale hook wiring claim(PreToolUse/.codex/hooks.json 主張)を実態に合わせて修正する - #2268

Merged
squne121 merged 7 commits into
mainfrom
worktree-issue-2262-stale-hook-wiring-claims
Aug 21, 2026
Merged

squne121 merged 7 commits into
mainfrom
worktree-issue-2262-stale-hook-wiring-claims

Conversation

@squne121

@squne121 squne121 commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

#2193/#2256 で確立した「hook は技術的強制ではなく Agent/Skill 側の behavioral contract として記述する」方針を repo 全体の残存箇所へ適用し、local_main_branch_guard / worktree_scope_guard が .claude/settings.json の PreToolUse や .codex/hooks.json に技術的に wiring されているという stale な主張を除去した。

  • .claude/hooks/local_main_branch_guard.sh: コメントを wrapper existence / project wiring / workflow authority の3点に分離して記述し直した(project .claude/settings.json の PreToolUse には登録されていない実態を明記)
  • .codex/hooks/local_main_branch_guard.sh: .codex/hooks.json が現在 SessionEnd/SubagentStop の passive advisory recorder のみである実態に合わせて修正
  • .codex/rules/default.rules: worktree_scope_guard が .codex/hooks.json に wiring されていない実態に合わせてコメントを修正
  • docs/dev/hook-boundaries.md:
    • 「PreToolUse hook 実行順序(Claude Code)」節(固定順序モデル)を除去し、「project settings に宣言されている PreToolUse handlers」相当の表現へ置換
    • pretool_fastpath_classifier.py 節から .codex/hooks.json の local_main_branch_guard.sh エントリという stale な主張を除去
    • hook_boundaries_manifest_v1(機械可読 SSOT)から local_main_branch_guard / worktree_scope_guard の active PreToolUse entry を除去(prose と機械可読 SSOT の drift を解消)
    • 「## 3. agent 判断表(Claude Code 向け)」と「## 4. agent 判断表(Codex CLI 向け)」の該当行も、project PreToolUse に未登録である旨と Codex parity の stale claim を修正
  • tests/test_hook_boundaries_doc.py: manifest 修正に伴い、#1690 の暫定 known-exception(drift 2件を許容していたアサーション)を drift-free assertion へ更新

repository-wide grep(PreToolUse hook / wired in / Invoked by .claude / Invoked by .codex / hooks.PreToolUse / hooks.PermissionRequest)を実行し、Allowed Paths 外にも同種の active stale claim がないことを確認済み(下記 Checks 参照)。

Checks

  • rg -n "Invoked by \.claude/settings\.json PreToolUse hook" .claude/hooks/local_main_branch_guard.sh → 0 件(PASS。修正前は 1 件ヒット)
  • rg -n "wired in \.codex/hooks\.json" .codex/rules/default.rules → 0 件(PASS。修正前は 1 件ヒット)
  • rg -n "PreToolUse hook 実行順序" docs/dev/hook-boundaries.md → 0 件(PASS。修正前は 1 件ヒット)
  • rg -n "local_main_branch_guard\.sh.*エントリ" docs/dev/hook-boundaries.md → 0 件(PASS。修正前は 1 件ヒット)
  • rg -n -e "PreToolUse hook" -e "wired in" -e "Invoked by \.claude" -e "Invoked by \.codex" -e "hooks\.PreToolUse" -e "hooks\.PermissionRequest" .claude/hooks/local_main_branch_guard.sh .codex/rules/default.rules docs/dev/hook-boundaries.md .codex/hooks/local_main_branch_guard.sh → 残り 1 件のみ(docs/dev/hook-boundaries.md:509「独立した PreToolUse hook として登録しない共有ライブラリ」)。これは explicit-negative(既に未 wired と明記)であり active stale claim ではない。分類: AC1-4/AC7 で扱った4箇所 = active stale claim(修正済み)、この1件 = explicit-negative(修正不要)
  • uv run --locked pytest tests/test_hook_boundaries_doc.py -q → 33 passed(PASS)
  • rg -n "Invoked by \.codex/hooks\.json hooks\.PreToolUse" .codex/hooks/local_main_branch_guard.sh → 0 件(PASS。修正前は 1 件ヒット)
  • uv run --locked python3 scripts/check_hook_boundaries.py → OK: manifest=8 entries, settings=8 entries — drift なし(PASS。修正前は 2 件の known-exception drift)
  • repository-wide grep(Allowed Paths 外を含む全 repo)で同キーワードを検索し、追加の active stale claim を確認 → 0 件(既存の hit は全て「独立した PreToolUse hook として登録しない共有ライブラリ」のような explicit-negative、または secret_boundary_guard.sh 等の実際に project PreToolUse に登録済みの hook を指す正当な記述のみ)
  • 本 Issue は Runtime Verification Applicability: decision: not_applicable(静的 docs/comment 修正のみ、hook 実行時挙動は変更なし)のため、TS/JS 変更なし。pnpm typecheck / pnpm lint / pnpm test / pnpm build は本 PR の変更ファイル(.sh / .rules / .md / tests/*.py)に対して適用対象外

Schema Change Applicability

schema_change_applicability_v1:
  - decision: not_schema_change

コメント・docs 記述・機械可読 manifest(hook_boundaries_manifest_v1)から stale なエントリを削除した変更であり、新規スキーマの導入やキー集合・型定義の変更は行っていない。既存 hook_boundaries_manifest_v1 の構造(handler_id / event / timeout 等のフィールド定義)自体は不変。

Schema Consumer Inventory

N/A(not_schema_change のため対象外)

Safety Claim Matrix

.claude/hooks/local_main_branch_guard.sh / .codex/hooks/local_main_branch_guard.sh / .codex/rules/default.rules / docs/dev/hook-boundaries.md / tests/test_hook_boundaries_doc.py の変更は docs/dev/workflow.md の safety-sensitive path pattern(transport / permission / sandbox / auth / mcp / .claude/skills/ / .github/workflows/)に該当しないため N/A(hook の実行時挙動は変更していない、コメント・docs・manifest・既存 test 期待値の静的修正のみ)。

一方、Scope Delta で追加した .claude/skills/post-merge-cleanup-executor/SKILL.md は .claude/skills/ パスとして safety-sensitive path pattern に該当するため、Matrix を明示する:

Claim Implemented Not controlled Evidence Follow-up
「agent からの bare git cleanup(git worktree remove / git branch -d 直接実行)は worktree_scope_guard が実行時に deny する」という旧 active-enforcement claim No(worktree_scope_guard は現行 project config で PreToolUse/PermissionRequest として wiring されていない) 実行時の deny 挙動そのもの(#1830 quarantine 済み、本 PR の対象外) check_hook_boundaries.py → OK: manifest=8 entries, settings=8 entries — drift なし。.claude/settings.json に worktree_scope_guard の PreToolUse エントリが存在しないことを目視確認済み なし(実際の safety boundary は既存の scripts/agent-ops/cleanup_exec.py 単一認可境界。本 PR は記述を実態に合わせただけで、cleanup フロー自体の変更ではない)
修正後の claim「worktree_scope_guard は behavioral/defense-in-depth contract として repo に残存するが、現行 project config では bare git cleanup を実行時に deny する active enforcement 経路ではない」 Yes(記述として明記) N/A diff(本 PR の .claude/skills/post-merge-cleanup-executor/SKILL.md 該当箇所)、.claude/settings.json の structural check なし
--consume 引数を agent が発行した場合に worktree_scope_guard.py の argv allowlist が実行時に deny するという旧 claim No(同上、project wiring なし) 実行時の deny 挙動(同上、#1830 quarantine 済み) 同上 なし(--consume は人間専用の運用ルールとして維持。worker はこのコマンドを自分で実行しない責務のまま不変)

いずれも hook の実行時挙動(enforcement 自体)を変更するものではなく、「何が実行時に deny しているか」という記述を実態(project wiring の有無)に合わせて修正したのみである。cleanup の実際の認可境界は既存どおり scripts/agent-ops/cleanup_exec.py に一本化されており、本 PR はこの安全境界を変更しない。

Scope Delta

Issue #2262 本文へ既に反映済み(Allowed Paths / Scope Delta 節を更新済み)。

OWNER REQUEST_CHANGES
(https://github.com/squne121/loop-protocol/pull/2268#issuecomment-5355203571)の
P1 指摘(repository-wide sweep が表層 grep に偏り、.codex/rules/default.rules の
arbitrates/denies 表現や .claude/skills/post-merge-cleanup-executor/SKILL.md の
現在形 active claim を取り逃がしている)に対応するため、guard 名(worktree_scope_guard /
local_main_branch_guard)起点の repo-wide semantic sweep で新たに検出した以下 3 ファイルを
Allowed Paths に追加し修正した。いずれも Issue #2262 の Outcome(stale active-enforcement
claim の除去、project wiring と behavioral contract の分離)と同一方針の記述修正であり、
新規契約・スキーマ変更は伴わない:

  • .claude/skills/post-merge-cleanup-executor/SKILL.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/session-recording-policy.md

Notes

linked Issue(Closes)と参照 Issue(Refs、#2193/#2256 のスコープ再オープンではない横展開参照)は以下のとおり:
Closes #2262
Refs #2193
Refs #2256

…修正する (#2262)

#2193/#2256 で確立した「hook は技術的強制ではなく Agent/Skill 側の
behavioral contract として記述する」方針を repo 全体の残存箇所へ適用する。

- .claude/hooks/local_main_branch_guard.sh: project .claude/settings.json
  PreToolUse に登録されていない実態に合わせ、wrapper existence / project
  wiring / workflow authority を分離して記述
- .codex/hooks/local_main_branch_guard.sh: .codex/hooks.json が
  SessionEnd/SubagentStop の passive recorder のみである実態に合わせて修正
- .codex/rules/default.rules: worktree_scope_guard が .codex/hooks.json に
  wiring されていない実態に合わせてコメント修正
- docs/dev/hook-boundaries.md: 固定 PreToolUse 実行順序の節を除去し
  project settings 宣言ベースの記述へ置換。hook_boundaries_manifest_v1 から
  local_main_branch_guard/worktree_scope_guard の active PreToolUse entry を
  除去し、agent 判断表・Codex parity 節の stale claim も修正
- tests/test_hook_boundaries_doc.py: manifest 修正に伴い drift-free
  assertion へ更新(#1690 の暫定 known-exception を解消)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2268 closed).

squne121 and others added 3 commits August 20, 2026 19:34
AC6 修正で hook_boundaries_manifest_v1 の local_main_branch_guard
PreToolUse entry を削除した際、同ブロック内にあった無関係な
gh CLI コマンド5分類(#1124)テーブルと allow 条件2節も誤って
削除されていた。PreToolUse wiring とは独立した guard 内部の
分類ロジックとして「## 3. agent 判断表」節末尾に復元する。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…eration 3)

CI python-test-core の 4 件の失敗を修正する。

- docs/dev/hook-boundaries.md に probe scripts (git_ref_probe.py /
  git_worktree_probe.py) が DETERMINISTIC_CHECKER_ALLOWLIST に登録済みである旨の
  記述を、gh CLI 5分類節(PreToolUse 未登録の behavioral contract として独立)に
  復元する。AC6 の manifest entry 削除で消えていた #1197 由来の記述を、stale
  wiring claim を再導入しない形で回復する。
- AC6 の manifest entry 削除により check_hook_boundaries.py の drift が旧 #1690
  既知 2 件から空集合へ変わったため、これを hard-code していた
  .claude/hooks/tests/test_generate_session_manifest_from_hook.py と
  .claude/hooks/tests/test_local_main_branch_guard.py の期待値を空集合へ更新する。

Scope Delta: 上記 2 テストファイルおよび shim である
scripts/agent-guards/tests/test_local_main_branch_guard.py を Allowed Paths に
追加(Issue #2262 本文で記録済み)。
CI PR Body Japanese Check が docs/dev/hook-boundaries.md の見出し「### deterministic_checker_command と probe scripts(#1197)」
(ratio=0.043, jp=1, total=23)を per-block 閾値 0.1 未満として fail させていた。
見出しに日本語プロースを追加し「登録範囲」という語を補って閾値を満たすよう修正した。
identifiers(deterministic_checker_command / probe scripts / #1197)の意味は変更していない。
@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT: APPROVE

impl-review-loop (Issue #2262) が 4 iteration(初回実装 + fix_delta ×3)を経て収束しました。

経緯

  • iteration 1: 初期実装(AC1-AC7 対象ファイルの stale wiring claim 除去)
  • iteration 2: AC6 の manifest entry 削除に伴い、無関係な gh CLI 5分類 table を誤って削除していた regression を修正
  • iteration 3: 同じく AC6 の副作用で probe scripts 言及が欠落し、#1690 既知 drift を hard-code していた 3 test file(Scope Delta で Allowed Paths 拡張済み)の期待値更新
  • iteration 4: docs/dev/hook-boundaries.md の新規見出しが per-block 日本語比率閾値を割っていた Japanese Check 失敗を修正

最終確認(head c3d98fe)

  • 全 CI green(python-test-core / e2e-core / e2e-responsive-matrix / visual-impact-policy(-trusted) / PR Body Japanese Check 含む)
  • mergeStateStatus: CLEAN, mergeable: MERGEABLE
  • AC1-AC7 全て diff ベースで独立検証済み
  • Allowed Paths(Scope Delta 拡張後の8ファイル)を diff は超えていない
verdict: APPROVE
reviewed_head_sha: "c3d98fe2bdeeaa322323727edfcc8009ecd9c486"
blockers: []
warnings: []

Draft PR のまま、マージは人間判断に委ねます。

@squne121

Copy link
Copy Markdown
Owner Author

結論

REQUEST_CHANGES を推奨します。

PR #2268 の方向性は正しく、current head c3d98fe2bdeeaa322323727edfcc8009ecd9c486 では通常 CI と hook-integrity workflow も成功しています。PR #1691 で local_main_branch_guard / worktree_scope_guard が project PreToolUse から外された事実、#1830 の Codex enforcing hook quarantine、#2193/#2256 の「project wiring と behavioral contract を分離する」方針にも概ね整合しています。

ただし、「repository-wide の stale hook wiring claim を除去した」という PR 自身の主要 claim はまだ成立していません。特に .codex/rules/default.rules には、この PR が直そうとしているのと同種の active-enforcement claim が同じ変更箇所に残っています。

Severity | 判定 | Finding -- | -- | -- P1 / merge blocker | 未解決 | .codex/rules/default.rules が未 wiring の worktree_scope_guard に現在も runtime arbitration を帰属している P1 / merge blocker | 未解決 | repository-wide sweep が lexical grep に偏り、実際の stale active-enforcement claim を取り逃がしている P1 / merge blocker | 未解決 | docs/dev/hook-boundaries.md が5本の current PreToolUse listを prose に再ハードコードし、#2262 で採った negative invariant を弱めている P2 | 修正推奨 | §3 の「以下の表は project PreToolUse behavioral contract」という説明が Stop/SubagentStop/PostToolUse 行まで包含している P2 / follow-up | 既存 debt | Codex validator の dormant 旧 topology expectation と、canonical docs の fail-open/fail-closed 表現に残る整合性 debt

P1 — .codex/rules/default.rules はまだ「guard が実際に裁定する」と主張している

今回の修正で、

wired in .codex/hooks.json

は確かに消えました。しかし、その直後のルールは現在も次の意味を持つ説明になっています。

git worktree remove は prompt なのに justification が “worktree_scope_guard arbitrates it against the V3 one-shot contract”、git branch -d も同じ、さらに force/rename 系では “the runtime hook also denies branch_force_delete_denied” と書かれています。

ところが current .codex/hooks.json は SessionEnd / SubagentStop の passive recorder だけで、worktree_scope_guard の PreToolUse / PermissionRequest wiring は存在しません。これは #1830 の明示的な quarantine 方針とも一致しています。

ここは単なる言葉尻ではありません。Codex の現行公式仕様では PreToolUse と PermissionRequest は明示的に設定する別々の hook event で、rules の approval/prompt と「任意の shell guard が呼ばれること」は同義ではありません。repo-local hook source と event wiring も公式に独立した設定として定義されています。(OpenAI Developers)

したがって、少なくともこの3箇所は次の意味へ直す必要があります。

prompt は Codex の approval boundary であり、現在の project config では worktree_scope_guard を呼ばない。canonical Agent/Skill cleanup path は cleanup_exec.py。worktree_scope_guard の実装は behavioral/defense-in-depth contract として残存するが、project hook wiring を主張しない。

この修正なしで merge すると、「wired」を消した直後に「arbitrates」「runtime hook denies」で同じ因果 claim を残すことになります。

P1 — 「repository-wide sweep 完了」は現状の検証方法では成立しない

PR body は repository-wide grep により「追加 active stale claim は 0」としていますが、具体的に提示された主要 grep は4ファイルに限定され、検索語も wired in / Invoked by ... / hooks.PreToolUse といった表層語彙です。

そのため、上記 .codex/rules/default.rules の arbitrates / runtime hook ... denies を取り逃がしています。さらに変更対象外の .claude/skills/post-merge-cleanup-executor/SKILL.md にも、

agent からの bare git cleanup は worktree_scope_guard が deny する

という現在形の technical-enforcement claim が残っています。同じ文書の後段では canonical cleanup path は cleanup_exec.py のみと定義しているため、こちらも「実装は存在する」「behavioral contract は存在する」「project hook が現在実行する」の3層を混同しています。

これは #2262 の事前敵対レビューで既に指摘された失敗モードそのものです。そこでは「単純な全件0 grep」ではなく、hit を active claim / historical / explicit-negative / その他 に意味分類することが要求されていました。

したがって次のどちらかが必要です。

  • 推奨: Scope Delta で .claude/skills/post-merge-cleanup-executor/SKILL.md まで直し、worktree_scope_guard / local_main_branch_guard を参照する repo-wide semantic inventory を再実施する。

  • スコープを広げないなら、PR title/body の repository-wide / 「追加 active stale claim 0」 を撤回し、未修正箇所を明示した follow-up Issue に切り出す。

前者を推奨します。

P1 — negative invariant を採ったのに、positive topology list を prose に再導入している

docs/dev/hook-boundaries.md の新しい §9 は固定実行順序を廃止した点は正しいです。しかしその直後に、

secret_boundary_guard / guard-japanese-prose / rtk_boundary_shadow_guard / ci_test_performance_advisory / root_temporary_residue_advisory が現在宣言されている

と、現在の5本を prose に再列挙しています。

これは現在の .claude/settings.json とは一致しています。

問題は「今正しいか」ではなく、#2262 のレビューで既に採用した設計原則に逆行している点です。元レビューでは明確に、

handler 数や current list を prose に固定せず、
local_main_branch_guard / worktree_scope_guard が project PreToolUse に存在しない

という negative invariant を authority にするよう要求されています。

しかも scripts/check_hook_boundaries.py の narrative checker は現在、session-manifest 関係の少数の固定 snippet だけを検査しており、この「5本の prose list」が future .claude/settings.json と drift しても検出しません。manifest 自体との structural comparison はありますが、この prose を生成・照合する仕組みではありません。

ここは5本の列挙を削除して、

repo-controlled .claude/settings.json の project PreToolUse に local_main_branch_guard / worktree_scope_guard は登録されていない。具体的な active handler topology の正本は hook_boundaries_manifest_v1 と .claude/settings.json の structural check とする。

までに絞るべきです。

これは今回の PR の目的である 「stale topology duplication の再発防止」 に直接関わるので merge blocker と評価します。

P2 — §3 の behavioral-contract qualifier の作用範囲が広すぎる

新しい §3 冒頭は、

以下の表は「project PreToolUse で実行された場合の behavioral contract」を記述する

としています。しかし、その表には session_manifest_coordinator.sh (Stop)、SubagentStop、session_manifest_debounce.mjs (PostToolUse) まで含まれます。

つまり local_main_branch_guard / worktree_scope_guard を説明するための qualifier が表全体へ掛かってしまっています。

ここは、

local_main_branch_guard / worktree_scope_guard の2行についてのみ、project PreToolUse 未登録の behavioral contract として記載する。

と限定すれば十分です。

外部仕様との照合で正しかった部分

固定順序の削除は正しいです。Claude Code の現行公式仕様では同一イベントに match した hooks は並列に走り、複数の updatedInput がある場合も完了順依存となるため deterministic な sibling order を前提にできません。今回 secret → local_main → worktree を削除した判断は適切です。(Claude)

Codex 側も、現在は repo-local .codex/hooks.json と .codex/config.toml、PreToolUse、PermissionRequest を公式にサポートしています。そのため PR が「Codex 自体に機能がない」ではなく、upstream capability と、この repository が #1830 で project hook を quarantine している事実を分離したのも正しい方向です。(OpenAI Developers) 現在の .codex/config.toml も hooks を有効にしたまま quarantine を維持する設計です。

.claude/hooks/local_main_branch_guard.sh と .codex/hooks/local_main_branch_guard.sh の wrapper existence / project wiring / workflow authority の3分離も、この PR の良い修正です。

推奨 fix delta

merge 前に、.codex/rules/default.rules の残存3 claim を修正 → docs/dev/hook-boundaries.md の positive 5-handler list を negative invariant 化 → §3 qualifier を限定 → repo 全体で guard 名を起点に semantic sweep → .claude/skills/post-merge-cleanup-executor/SKILL.md を修正または明示的 follow-up 化、までを1 iteration 追加するのが妥当です。

その後、scripts/check_hook_boundaries.py と既存 tests に加えて、単なる "wired in" grep ではなく、local_main_branch_guard / worktree_scope_guard を参照する全 production docs/rules/skills を列挙し、各 hit に project-wired / behavioral-only / historical / explicit-negative の分類を持たせる deterministic check を入れると、今回と同じ drift の再発率をかなり下げられます。

現 HEAD は runtime regression の兆候はなく CI も green ですが、PR の主目的である「宣言上の因果関係を正しくする」作業としてはまだ未完了です。したがって現時点では APPROVE ではなく REQUEST_CHANGES が適切です。

## 結論

REQUEST_CHANGES を推奨します。

PR #2268 の方向性は正しく、current head c3d98fe2bdeeaa322323727edfcc8009ecd9c486 では通常 CI と hook-integrity workflow も成功しています。PR #1691 で local_main_branch_guard / worktree_scope_guard が project PreToolUse から外された事実、#1830 の Codex enforcing hook quarantine、#2193/#2256 の「project wiring と behavioral contract を分離する」方針にも概ね整合しています。

ただし、「repository-wide の stale hook wiring claim を除去した」という PR 自身の主要 claim はまだ成立していません。特に .codex/rules/default.rules には、この PR が直そうとしているのと同種の active-enforcement claim が同じ変更箇所に残っています。

Severity 判定 Finding
P1 / merge blocker 未解決 .codex/rules/default.rules が未 wiring の worktree_scope_guard に現在も runtime arbitration を帰属している
P1 / merge blocker 未解決 repository-wide sweep が lexical grep に偏り、実際の stale active-enforcement claim を取り逃がしている
P1 / merge blocker 未解決 docs/dev/hook-boundaries.md が5本の current PreToolUse listを prose に再ハードコードし、#2262 で採った negative invariant を弱めている
P2 修正推奨 §3 の「以下の表は project PreToolUse behavioral contract」という説明が Stop/SubagentStop/PostToolUse 行まで包含している
P2 / follow-up 既存 debt Codex validator の dormant 旧 topology expectation と、canonical docs の fail-open/fail-closed 表現に残る整合性 debt

P1 — .codex/rules/default.rules はまだ「guard が実際に裁定する」と主張している

今回の修正で、

wired in .codex/hooks.json

は確かに消えました。しかし、その直後のルールは現在も次の意味を持つ説明になっています。

git worktree remove は prompt なのに justification が “worktree_scope_guard arbitrates it against the V3 one-shot contract”、git branch -d も同じ、さらに force/rename 系では “the runtime hook also denies branch_force_delete_denied” と書かれています。

ところが current .codex/hooks.json は SessionEnd / SubagentStop の passive recorder だけで、worktree_scope_guard の PreToolUse / PermissionRequest wiring は存在しません。これは #1830 の明示的な quarantine 方針とも一致しています。

ここは単なる言葉尻ではありません。Codex の現行公式仕様では PreToolUse と PermissionRequest は明示的に設定する別々の hook event で、rules の approval/prompt と「任意の shell guard が呼ばれること」は同義ではありません。repo-local hook source と event wiring も公式に独立した設定として定義されています。([OpenAI Developers]1)

したがって、少なくともこの3箇所は次の意味へ直す必要があります。

prompt は Codex の approval boundary であり、現在の project config では worktree_scope_guard を呼ばない。canonical Agent/Skill cleanup path は cleanup_exec.py。worktree_scope_guard の実装は behavioral/defense-in-depth contract として残存するが、project hook wiring を主張しない。

この修正なしで merge すると、「wired」を消した直後に「arbitrates」「runtime hook denies」で同じ因果 claim を残すことになります。

P1 — 「repository-wide sweep 完了」は現状の検証方法では成立しない

PR body は repository-wide grep により「追加 active stale claim は 0」としていますが、具体的に提示された主要 grep は4ファイルに限定され、検索語も wired in / Invoked by ... / hooks.PreToolUse といった表層語彙です。

そのため、上記 .codex/rules/default.rules の arbitrates / runtime hook ... denies を取り逃がしています。さらに変更対象外の .claude/skills/post-merge-cleanup-executor/SKILL.md にも、

agent からの bare git cleanup は worktree_scope_guard が deny する

という現在形の technical-enforcement claim が残っています。同じ文書の後段では canonical cleanup path は cleanup_exec.py のみと定義しているため、こちらも「実装は存在する」「behavioral contract は存在する」「project hook が現在実行する」の3層を混同しています。

これは #2262 の事前敵対レビューで既に指摘された失敗モードそのものです。そこでは「単純な全件0 grep」ではなく、hit を active claim / historical / explicit-negative / その他 に意味分類することが要求されていました。

したがって次のどちらかが必要です。

  • 推奨: Scope Delta で .claude/skills/post-merge-cleanup-executor/SKILL.md まで直し、worktree_scope_guard / local_main_branch_guard を参照する repo-wide semantic inventory を再実施する。
  • スコープを広げないなら、PR title/body の repository-wide / 「追加 active stale claim 0」 を撤回し、未修正箇所を明示した follow-up Issue に切り出す。

前者を推奨します。

P1 — negative invariant を採ったのに、positive topology list を prose に再導入している

docs/dev/hook-boundaries.md の新しい §9 は固定実行順序を廃止した点は正しいです。しかしその直後に、

secret_boundary_guard / guard-japanese-prose / rtk_boundary_shadow_guard / ci_test_performance_advisory / root_temporary_residue_advisory が現在宣言されている

と、現在の5本を prose に再列挙しています。

これは現在の .claude/settings.json とは一致しています。

問題は「今正しいか」ではなく、#2262 のレビューで既に採用した設計原則に逆行している点です。元レビューでは明確に、

handler 数や current list を prose に固定せず、
local_main_branch_guard / worktree_scope_guard が project PreToolUse に存在しない

という negative invariant を authority にするよう要求されています。

しかも scripts/check_hook_boundaries.py の narrative checker は現在、session-manifest 関係の少数の固定 snippet だけを検査しており、この「5本の prose list」が future .claude/settings.json と drift しても検出しません。manifest 自体との structural comparison はありますが、この prose を生成・照合する仕組みではありません。

ここは5本の列挙を削除して、

repo-controlled .claude/settings.json の project PreToolUse に local_main_branch_guard / worktree_scope_guard は登録されていない。具体的な active handler topology の正本は hook_boundaries_manifest_v1 と .claude/settings.json の structural check とする。

までに絞るべきです。

これは今回の PR の目的である 「stale topology duplication の再発防止」 に直接関わるので merge blocker と評価します。

P2 — §3 の behavioral-contract qualifier の作用範囲が広すぎる

新しい §3 冒頭は、

以下の表は「project PreToolUse で実行された場合の behavioral contract」を記述する

としています。しかし、その表には session_manifest_coordinator.sh (Stop)、SubagentStop、session_manifest_debounce.mjs (PostToolUse) まで含まれます。

つまり local_main_branch_guard / worktree_scope_guard を説明するための qualifier が表全体へ掛かってしまっています。

ここは、

local_main_branch_guard / worktree_scope_guard の2行についてのみ、project PreToolUse 未登録の behavioral contract として記載する。

と限定すれば十分です。

外部仕様との照合で正しかった部分

固定順序の削除は正しいです。Claude Code の現行公式仕様では同一イベントに match した hooks は並列に走り、複数の updatedInput がある場合も完了順依存となるため deterministic な sibling order を前提にできません。今回 secret → local_main → worktree を削除した判断は適切です。(Claude)

Codex 側も、現在は repo-local .codex/hooks.json と .codex/config.toml、PreToolUse、PermissionRequest を公式にサポートしています。そのため PR が「Codex 自体に機能がない」ではなく、upstream capability と、この repository が #1830 で project hook を quarantine している事実を分離したのも正しい方向です。([OpenAI Developers]1) 現在の .codex/config.toml も hooks を有効にしたまま quarantine を維持する設計です。

.claude/hooks/local_main_branch_guard.sh と .codex/hooks/local_main_branch_guard.sh の wrapper existence / project wiring / workflow authority の3分離も、この PR の良い修正です。

推奨 fix delta

merge 前に、.codex/rules/default.rules の残存3 claim を修正 → docs/dev/hook-boundaries.md の positive 5-handler list を negative invariant 化 → §3 qualifier を限定 → repo 全体で guard 名を起点に semantic sweep → .claude/skills/post-merge-cleanup-executor/SKILL.md を修正または明示的 follow-up 化、までを1 iteration 追加するのが妥当です。

その後、scripts/check_hook_boundaries.py と既存 tests に加えて、単なる "wired in" grep ではなく、local_main_branch_guard / worktree_scope_guard を参照する全 production docs/rules/skills を列挙し、各 hit に project-wired / behavioral-only / historical / explicit-negative の分類を持たせる deterministic check を入れると、今回と同じ drift の再発率をかなり下げられます。

現 HEAD は runtime regression の兆候はなく CI も green ですが、PR の主目的である「宣言上の因果関係を正しくする」作業としてはまだ未完了です。したがって現時点では APPROVE ではなく REQUEST_CHANGES が適切です。

…ep で見つかった active claim を修正 (#2262)

PR #2268 への OWNER REQUEST_CHANGES (comment 5355203571) の fix_delta 対応。

P1 (merge blocker):
- .codex/rules/default.rules: git worktree remove / git branch -d / force-rename
  branch の3 justification に残っていた「worktree_scope_guard が arbitrate/deny する」
  という現在形の因果主張を、非 wiring 実態(.codex/hooks.json は SessionEnd/SubagentStop
  passive recorder のみ)に合わせて修正
- 意味ベースの repository-wide sweep(arbitrates/denies/wired/block される 等)で
  以下の active claim を追加検出し修正:
  - .claude/skills/post-merge-cleanup-executor/SKILL.md(Scope Delta)
  - docs/dev/agent-skill-boundaries.md(Scope Delta)
  - docs/dev/session-recording-policy.md(Scope Delta。#783 由来の
    「active PreToolUse handlers」節見出し・prose を historical 化)
  - docs/dev/hook-boundaries.md(既存 Allowed Paths 内。§12/§12c/§12d の
    「block される」現在形記述を behavioral contract 表現へ修正)
- docs/dev/hook-boundaries.md §9: 5 handler の positive list 列挙を削除し、
  hook_boundaries_manifest_v1 + check_hook_boundaries.py を authority とする
  negative invariant 表現に統一

P2:
- docs/dev/hook-boundaries.md §3: 「project PreToolUse behavioral contract」の
  qualifier を local_main_branch_guard / worktree_scope_guard の2行に限定

分類結果(要約): 上記 active claim 修正箇所以外の worktree_scope_guard /
local_main_branch_guard 言及は、explicit-negative(既に #1691 未wiring と明記)
または historical/code-reference(テストファイル名・import文・classifier registry
コード等)であり、追加の active claim は見つからなかった。

Scope Delta: 元 Issue #2262 の Allowed Paths に含まれない
.claude/skills/post-merge-cleanup-executor/SKILL.md / docs/dev/agent-skill-boundaries.md /
docs/dev/session-recording-policy.md を OWNER 指摘に基づき追加編集した。
@squne121

Copy link
Copy Markdown
Owner Author

OWNER REQUEST_CHANGES 対応(fix_delta、head 8efd8200)

#2268 (comment) の指摘に対応しました。

P1(merge blocker)対応

  1. .codex/rules/default.rules の残存3claim — git worktree remove / git branch -d / force-rename branch の justification から「worktree_scope_guard arbitrates/denies」という現在形の因果主張を除去し、prompt が Codex approval boundary であること・worktree_scope_guard は behavioral/defense-in-depth contract として repo に残存するが .codex/hooks.json の PreToolUse/PermissionRequest としては wiring されていないこと、を明記する表現に置き換えました(codex execpolicy check で decision(prompt/forbidden)が不変であることを確認済み)。

  2. repository-wide semantic sweep — worktree_scope_guard / local_main_branch_guard を repo 全体(テストファイル・実装コードを含む)で検索し、意味分類しました。

    分類結果:

    • active claim(修正対象): .claude/skills/post-merge-cleanup-executor/SKILL.md(2箇所)、docs/dev/agent-skill-boundaries.md(3箇所)、docs/dev/session-recording-policy.md(## active PreToolUse handlers 節見出し+prose、#783由来)、docs/dev/hook-boundaries.md §12/§12c/§12d(3箇所、既存 Allowed Paths 内)— いずれも修正済み
    • explicit-negative(修正不要): .claude/agents/pr-reviewer.md、.claude/agents/scope-rollup-runner.md、.claude/skills/impl-review-loop/steps/preparation.md、.claude/skills/pr-review-judge/SKILL.md — 既に「chore: local_main_branch_guard / worktree_scope_guard の2 hook を緊急停止する #1691 で wiring されていない」と明記済み
    • historical / code-reference(対象外): テストファイル名参照(tests/codex/test_local_main_branch_guard.py 等)、Python import 文、classifier registry のコード上の登録記述(例: docs/dev/hook-boundaries.md:674 の scope_rollup.run classifier 登録は code-level registry の事実であり PreToolUse wiring 主張ではない)

    .claude/skills/post-merge-cleanup-executor/SKILL.md・docs/dev/agent-skill-boundaries.md・docs/dev/session-recording-policy.md は元 Issue 実装: repository-wide の stale hook wiring claim(PreToolUse/.codex/hooks.json 主張)を実態に合わせて修正する #2262 の Allowed Paths に含まれないため、Scope Delta として追加編集しました。

  3. docs/dev/hook-boundaries.md §9 — 5 handler(secret_boundary_guard 等)の positive list 列挙を削除し、hook_boundaries_manifest_v1(機械可読 SSOT)と scripts/check_hook_boundaries.py の structural check を authority とする negative invariant のみの表現に統一しました。

P2(推奨)対応

  1. docs/dev/hook-boundaries.md §3 の「project PreToolUse behavioral contract」という qualifier の適用範囲を local_main_branch_guard.sh / worktree_scope_guard.sh の2行に限定し、他行(secret_boundary_guard.sh 等の登録済み handler、session_manifest_coordinator.sh / session_manifest_debounce.mjs 等の Stop/SubagentStop/PostToolUse handler)はそれぞれ実際の登録イベントの挙動を記述する旨を明記しました。

  2. Codex validator の dormant 旧 topology expectation と canonical docs の fail-open/fail-closed 表現の整合性 debt は、今回のスコープ外として 触っていません(follow-up Issue 化は今回見送り)。

検証結果

  • Issue 実装: repository-wide の stale hook wiring claim(PreToolUse/.codex/hooks.json 主張)を実態に合わせて修正する #2262 の AC1〜AC4, AC7 grep: いずれも exit 1(マッチなし = stale claim 除去済み)
  • AC5 sweep(Allowed Paths narrow 版 + repo-wide 版): 残存 hit は explicit-negative のみ
  • AC6: uv run --locked pytest tests/test_hook_boundaries_doc.py -q → 33 passed
  • uv run --locked python3 scripts/check_hook_boundaries.py → OK(drift なし)
  • pnpm typecheck / pnpm lint / pnpm test(1872 passed)/ pnpm build → 全 green
  • uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py → 24 passed
  • validate_japanese_content.py を変更した4つの .md ファイル全てに実行 → 全 PASS
  • Scope Delta 3ファイルに対応する既存テスト(tests/test_post_merge_cleanup_boundary.py 57 passed、.claude/scripts/check_session_recording_policy.py、.claude/hooks/tests/test_session_recording_policy_guard.py 24 passed)→ 全 PASS
  • tests/agent_guards/ + scripts/agent-guards/tests/ の一括実行で73件 fail していますが、変更前 baseline(stash して同一実行)でも同じ4件が uv_not_found 環境要因で fail することを確認済みで、今回の diff との因果関係はありません(未修正の pre-existing environment issue)

new head: 8efd820013032c257571afad86a80c61d426e8fc

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST_CHANGES

Mergeability

  • mergeable=MERGEABLE, merge_state_status=CLEAN

Blockers

確認済み事項(参考、blocker ではない)

  • OWNER 指摘の P1×2(.codex/rules/default.rules の現在形因果主張3箇所、
    docs/dev/hook-boundaries.md §9 の positive 5-handler list)は解消を確認した。
  • CI: 26 checks 中 non-success 0件(全 SUCCESS/SKIPPED)。
verdict: REQUEST_CHANGES
reviewed_head_sha: "8efd820013032c257571afad86a80c61d426e8fc"
blockers:
  - "Allowed Paths Gate fail_closed: .claude/skills/post-merge-cleanup-executor/SKILL.md / docs/dev/agent-skill-boundaries.md / docs/dev/session-recording-policy.md are not in live Issue #2262 Allowed Paths nor its Scope Delta section; the corresponding Scope Delta was posted only as a PR comment, not reflected in the canonical live issue body or PR body"
warnings: []

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

確認結果

  1. Allowed Paths Gate: allowed_paths_review_gate.py(live Issue 実装: repository-wide の stale hook wiring claim(PreToolUse/.codex/hooks.json 主張)を実態に合わせて修正する #2262 本文由来)を実行し status: ok(changed_files_count: 10、violations: [])。canonical Allowed Paths(8ファイル + Scope Delta 3ファイル = 11エントリ)と実際の変更ファイル10件が完全一致。

  2. Safety Claim Matrix: .claude/skills/post-merge-cleanup-executor/SKILL.md の diff と Matrix の記載内容の整合を確認。.claude/settings.json に worktree_scope_guard / local_main_branch_guard の PreToolUse エントリが存在しないことを独立確認済み。

  3. Mergeability / CI: mergeable: MERGEABLE, merge_state_status: CLEAN。required checks(python-test, typecheck, test, lint, build, validate-generated-artifact)はいずれも最新 workflow run(32366356731)で SUCCESS。visual-impact-policy-trusted は non-required(既知の CI infra debt、実装: visual-impact-trusted-consumer.yml の gh api --output 未対応バグを修正する #2076 で別トラック)。

  4. 新規 blocker: なし。

verdict: APPROVE
reviewed_head_sha: "8efd820013032c257571afad86a80c61d426e8fc"
blockers: []
warnings:
  - "PR body lacks the standard '## 受け入れ条件の達成状況' heading with per-AC [x]/[ ] checkboxes; AC evidence is instead embedded in the '## Checks' section (content coverage appears complete, format non-standard)"

@squne121
squne121 merged commit 59c323a into main Aug 21, 2026
25 checks passed
@squne121
squne121 deleted the worktree-issue-2262-stale-hook-wiring-claims branch August 21, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: repository-wide の stale hook wiring claim(PreToolUse/.codex/hooks.json 主張)を実態に合わせて修正する

1 participant