Skip to content

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

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "#2193/#2256 で確立した「hook は技術的強制ではなく behavioral contract として記述する」方針を、repo 全体に残る stale wiring claim へ適用する"
change_kind: docs

Parent Issue

なし(単独改善)

Parent Goal Ref

Current Validated Scope

  • .claude/hooks/local_main_branch_guard.sh の 2, 7, 8 行目付近のコメント(Claude Code PreToolUse wrapper / Invoked by .claude/settings.json PreToolUse hook. / Order: secret_boundary_guard -> local_main_branch_guard -> worktree_scope_guard)を修正する
  • .codex/hooks/local_main_branch_guard.sh のコメント(Invoked by .codex/hooks.json hooks.PreToolUse and hooks.PermissionRequest.)を、現行 .codex/hooks.json が SessionEnd/SubagentStop の passive recorder のみである実態に合わせて修正する
  • .codex/rules/default.rules の 462-463 行目付近(# (the guarded cleanup route, wired in .codex/hooks.json) against the V3 one-shot)を修正する
  • docs/dev/hook-boundaries.md の以下の箇所を修正する:
    • 619-621 行目付近「PreToolUse hook 実行順序(Claude Code): secret_boundary_guard → local_main_branch_guard → worktree_scope_guard → その他」という節名・固定順序モデルを、Claude Code の実際の hook 実行 semantics(同一イベントで match した複数 hooks は parallel 実行され順序は non-deterministic)に整合する表現(「project settings に宣言されている PreToolUse handlers」相当)へ置き換える
    • 629 行目付近「Bash ラッパー経由で .codex/hooks.json の local_main_branch_guard.sh エントリ」(現行 .codex/hooks.json は SessionEnd / SubagentStop の advisory recording hook のみで local_main_branch_guard.sh エントリは存在しない)
    • hook_boundaries_manifest_v1(機械可読 SSOT)から local_main_branch_guard / worktree_scope_guard の active PreToolUse entry、および固定 hook 実行順序の主張を除去する(prose と機械可読 SSOT の drift を解消する)
  • tests/test_hook_boundaries_doc.py の既存テストのうち、hook_boundaries_manifest_v1 の上記2 guard の drift を既知例外として明示的に期待している箇所を、manifest 修正後の期待値に追随して更新する
  • 上記以外の同種箇所は repository-wide grep で洗い出し、見つかった場合は同じ Allowed Paths 追加方針で修正する(本 Issue の Scope Delta として記録可能な範囲。新規ファイルが必要な場合は Stop Conditions に従い一旦停止し報告する)

Remaining Parent Gaps

  • なし(本 Issue で対象範囲を完結させる。ただし grep 洗い出しの結果、Allowed Paths に含まれない大規模書き換えが必要と判明した場合は Stop Conditions に従い follow-up Issue 化する)

Outcome

.claude/hooks/local_main_branch_guard.sh・.codex/hooks/local_main_branch_guard.sh・.codex/rules/default.rules・docs/dev/hook-boundaries.md(prose 節と hook_boundaries_manifest_v1 の両方)・tests/test_hook_boundaries_doc.py(および repository-wide grep で追加検出された同種ファイル)のコメント・docs 記述・機械可読 SSOT から、「local_main_branch_guard / worktree_scope_guard が .claude/settings.json の PreToolUse や .codex/hooks.json に技術的に wiring されている」という stale な主張が除去された状態。

authority は以下の negative invariant に限定する(具体的な PreToolUse handler 数や secret_boundary_guard のみといった cardinality を prose に固定しない):

  • repo-controlled .claude/settings.json の project PreToolUse に local_main_branch_guard / worktree_scope_guard が存在しないこと
  • repo-controlled .codex/hooks.json に local_main_branch_guard.sh を PreToolUse/PermissionRequest として呼び出すエントリが存在しないこと

また、project configuration(repo-controlled .claude/settings.json / .codex/hooks.json に何が宣言されているか)と effective runtime(実際に実行時に何が dispatch されるか。user settings / local settings / managed policy / plugin 等の他 layer や runtime 側の未解決事象を含みうる)を区別し、本 Issue の主張は project configuration の宣言状態に限定する。修正後の rg 検証・check_hook_boundaries.py・test_hook_boundaries_doc.py が全て PASS している状態を完了条件とする。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: コメント・docs・機械可読 manifest・既存テスト期待値の静的修正のみであり、hook の実行時挙動そのものは変更しないため

In Scope

  • .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 のコメントから「Invoked by .codex/hooks.json hooks.PreToolUse and hooks.PermissionRequest.」という stale claim を除去し、現行実態(.codex/hooks.json は SessionEnd/SubagentStop の passive recorder のみ)に整合する記述へ修正する
  • .codex/rules/default.rules の該当コメントを、worktree_scope_guard が .codex/hooks.json に wiring されていない実態に合わせて修正する
  • docs/dev/hook-boundaries.md について以下を修正する:
    • 「PreToolUse hook 実行順序(Claude Code)」という節名・概念自体を、Claude Code 公式仕様(同一イベントで match した複数 hooks は parallel 実行され順序は non-deterministic)に整合する「project settings に宣言されている PreToolUse handlers」相当の表現へ置き換える
    • secret_boundary_guard → local_main_branch_guard → worktree_scope_guard という固定 hook 実行順序の主張を除去する
    • pretool_fastpath_classifier.py 節の該当記述(.codex/hooks.json の local_main_branch_guard.sh エントリ主張)を修正する
    • hook_boundaries_manifest_v1(機械可読 SSOT)から local_main_branch_guard / worktree_scope_guard の active PreToolUse entry、および固定 hook order の記述を除去する
  • tests/test_hook_boundaries_doc.py の既存テストのうち、hook_boundaries_manifest_v1 修正に伴い期待値変更が必要な箇所(2 guard の drift を既知例外として期待している既存アサーション)を更新する
  • 上記以外のファイル(.claude/hooks/*.sh の他ファイル、.claude/agents/*.md、docs/dev/*.md 等)を対象に、以下のキーワードで repository-wide grep を実行し、同種の stale wiring claim が残っていないか洗い出す:
    • PreToolUse hook
    • wired in
    • Invoked by .claude
    • Invoked by .codex
    • hooks.PreToolUse
    • hooks.PermissionRequest
    • 洗い出しで見つかった追加箇所も、Allowed Paths の範囲内であれば同一方針で修正する
  • scripts/check_hook_boundaries.py は docs/dev/hook-boundaries.md の hook_boundaries_manifest_v1 と .claude/settings.json を構造照合するスクリプトであり、tests/test_hook_boundaries_doc.py の pytest 実行がこのスクリプトの整合性も間接的に検証する(Verification Commands では独立したコマンドとしては実行しない)

Out of Scope

Acceptance Criteria

  • AC1: .claude/hooks/local_main_branch_guard.sh のコメントから「.claude/settings.json PreToolUse hook から呼ばれる」という stale な文言が除去され、以下 3 点を分離して記述する: (a) wrapper existence(.claude/hooks/local_main_branch_guard.sh は repo に残存している)、(b) project wiring(repo-controlled .claude/settings.json の project PreToolUse からは登録されていない)、(c) workflow authority(policy の authority は Agent/Skill 側の behavioral contract にあるが、その behavioral contract がこの shell wrapper を実行しているとは主張しない)
  • AC2: .codex/rules/default.rules の 462-463 行目付近から「wired in .codex/hooks.json」という stale な文言が除去され、現行実態に合わせた記述に置き換わっている
  • AC3: docs/dev/hook-boundaries.md の「PreToolUse hook 実行順序(Claude Code)」節が除去され、「project settings に宣言されている PreToolUse handlers」相当の表現に置き換わっている。固定順序(secret_boundary_guard → local_main_branch_guard → worktree_scope_guard 等)の主張を含まず、「repo-controlled .claude/settings.json の project PreToolUse に local_main_branch_guard / worktree_scope_guard が存在しない」という negative invariant として記述されている
  • AC4: docs/dev/hook-boundaries.md の pretool_fastpath_classifier.py 節から「.codex/hooks.json の local_main_branch_guard.sh エントリ」という stale な主張が除去されている
  • AC5: 本 Issue の Allowed Paths 内の対象ファイルを対象とした grep(PreToolUse hook / wired in / Invoked by .claude / Invoked by .codex / hooks.PreToolUse / hooks.PermissionRequest キーワード)の実行結果が Issue コメントまたは PR 本文に記録され、各 hit が active stale claim / historical note / explicit-negative(既に未 wired と明記)/ その他のいずれかに意味分類されている。AC1-4, AC6, AC7 で扱った箇所以外に active stale claim が残っていないことが確認されている(残っていた場合は同一方針で修正されている)
  • AC6: docs/dev/hook-boundaries.md 内の hook_boundaries_manifest_v1(機械可読 SSOT)から local_main_branch_guard / worktree_scope_guard の active PreToolUse entry が除去され、tests/test_hook_boundaries_doc.py の既存テスト期待値がこの変更に追随して更新されている
  • AC7: .codex/hooks/local_main_branch_guard.sh のコメントから「Invoked by .codex/hooks.json hooks.PreToolUse and hooks.PermissionRequest.」という stale claim が除去され、現行実態(.codex/hooks.json は SessionEnd/SubagentStop の passive recorder のみ)に整合する記述に修正されている

Verification Commands

# AC1
# baseline-expect: pass
$ rg -n "Invoked by \.claude/settings\.json PreToolUse hook" .claude/hooks/local_main_branch_guard.sh

# AC2
# baseline-expect: pass
$ rg -n "wired in \.codex/hooks\.json" .codex/rules/default.rules

# AC3
# baseline-expect: pass
$ rg -n "PreToolUse hook 実行順序" docs/dev/hook-boundaries.md

# AC4
# baseline-expect: pass
$ rg -n "local_main_branch_guard\.sh.*エントリ" docs/dev/hook-boundaries.md

# AC5
# baseline-expect: pass
$ 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

# AC6
$ uv run --locked pytest tests/test_hook_boundaries_doc.py -q

# AC7
# baseline-expect: pass
$ rg -n "Invoked by \.codex/hooks\.json hooks\.PreToolUse" .codex/hooks/local_main_branch_guard.sh

上記 AC1〜AC4, AC7 の grep コマンドは、修正前の baseline では stale claim がまだ残っているため grep が match する(exit 0)ことを期待値とする(baseline-expect: pass コメントの意味)。修正後は AC の記述どおり 0 件(マッチなし、exit 1)であることを確認する。AC5 は repository-wide grep の実行結果として、全 hit を active stale claim / historical note / explicit-negative / その他に意味分類し、AC1〜AC4, AC6, AC7 で扱った箇所以外の active stale claim が 0 件であることを Issue コメントまたは PR 本文に記録する。検索対象は本 Issue の Allowed Paths に含まれる具体的ファイル(.claude/hooks/local_main_branch_guard.sh・.codex/rules/default.rules・docs/dev/hook-boundaries.md・.codex/hooks/local_main_branch_guard.sh)へ narrow し、AC1-4/AC7 の個別コマンドがカバーしていない表現も含めて統合的に確認する。tests/test_hook_boundaries_doc.py はテストファイルであり stale claim 文言の走査対象として意味を持たないため、この rg には含めない。他に既知の stale claim 箇所が見つかった場合は、本 Issue の Allowed Paths の範囲内であれば同様にファイルを追加列挙する(Allowed Paths 外の追加箇所は Scope Delta または follow-up Issue で扱う)。AC6 は uv run --locked pytest tests/test_hook_boundaries_doc.py -q が全テスト PASS することを確認する(scripts/check_hook_boundaries.py は docs/dev/hook-boundaries.md の hook_boundaries_manifest_v1 と .claude/settings.json を構造照合するため、このテストは同スクリプトの整合性も間接的に検証する)。

Allowed Paths

  • .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
  • .claude/hooks/tests/test_generate_session_manifest_from_hook.py
  • .claude/hooks/tests/test_local_main_branch_guard.py
  • scripts/agent-guards/tests/test_local_main_branch_guard.py
  • .claude/skills/post-merge-cleanup-executor/SKILL.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/session-recording-policy.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合(例: repository-wide grep で発見された追加箇所が上記 5 ファイル以外の場合、Scope Delta として提案するか、規模が大きい場合は follow-up Issue を起票する)
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • docs/dev/hook-boundaries.md
  • docs/dev/agent-skill-boundaries.md

Scope Delta(該当時のみ記載)

AC6 の manifest entry 削除(hook_boundaries_manifest_v1 から local_main_branch_guard /
worktree_scope_guard の active PreToolUse entry を除去)により、旧 #1690 既知 drift(2件)を
hard-code していた既存テストの期待値が空集合(drift なし)に追随する必要が生じたため、以下 3
ファイルを Allowed Paths に追加する:

  • .claude/hooks/tests/test_generate_session_manifest_from_hook.py
  • .claude/hooks/tests/test_local_main_branch_guard.py
  • scripts/agent-guards/tests/test_local_main_branch_guard.py

PR #2268 に対する 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 の Outcome(stale active-enforcement claim の除去、
project wiring と behavioral contract の分離)と同一方針の記述修正であり、新規契約・スキーマ
変更は伴わない:

  • .claude/skills/post-merge-cleanup-executor/SKILL.md(「agent からの bare git cleanup は
    worktree_scope_guard が deny する」という現在形 claim を、現行 project wiring の実態に
    合わせて修正)
  • docs/dev/agent-skill-boundaries.md(controlled_skill_mutation_exec 節の同種 active claim
    3 箇所を修正)
  • docs/dev/session-recording-policy.md(実装: PreToolUse guard の誤検知緩和と理由分類・診断検証を追加する #783 由来の「active PreToolUse handlers」節見出し・
    冒頭文を historical 表現へ修正)

Delivery Rule

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 19, 2026
  2. squne121 commented on Aug 19, 2026

    @squne121
    OwnerAuthor

    Scope Collision advisory (C1, non-blocking per #1860 Owner Decision): Allowed Paths のテキスト重複が overlap preflight で検出されました(related_issue=#2192, #2007, #1881, #1601, #1595, #1432, #1093, #237, #225, #224, #213; overlapping_paths=.claude/hooks/local_main_branch_guard.sh, .codex/rules/default.rules, docs/dev/hook-boundaries.md)。大半は broad path(docs/dev, .claude/hooks 等)マッチによる false positive で、いずれも本 Issue と同時に OPEN 状態で同一の狭い anchor(局所コメント文言)を編集する計画はない。実 conflict は worktree/PR 作成時に別途検出される想定。

  3. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    結論

    Issue #2262 は REQUEST_CHANGES。現状のまま実装着手すべきではありません。

    PR #2256 で切り出した「repository-wide の stale hook wiring claim を掃除する」という方向自体は妥当です。しかし #2262 は、stale claim を直す Issue 自身が stale な topology を前提にしており、さらに既知の stale 箇所が Allowed Paths 外に残っています。加えて Claude Code の現行 hook 実行 semantics とも一部衝突しています。

    P0-1 — AC3 / Outcome の基準状態が事実と違う

    #2262 は Outcome と AC3 で「.claude/settings.json の PreToolUse は secret_boundary_guard のみ」と固定しています。

    しかし current main の .claude/settings.json には PreToolUse が5本あります。

    secret_boundary_guard、guard-japanese-prose、rtk_boundary_shadow_guard、ci_test_performance_advisory、root_temporary_residue_advisory です。

    しかもこれは最近 main が動いたせいではありません。PR #1691 は明示的に local_main_branch_guard / worktree_scope_guard の2本だけを外し、上記5本を復元する設計でした。

    したがって AC3 は「現在の5本をハードコード」するより、

    repo-controlled .claude/settings.json の PreToolUse に
    local_main_branch_guard / worktree_scope_guard が存在しない

    という negative invariant に直すべきです。current cardinality を prose に複製すると再び drift します。

    P0-2 — hook_boundaries_manifest_v1 という本物のSSOTを修正対象から事実上漏らしている

    これは #2262 の最大の構造的欠陥です。

    docs/dev/hook-boundaries.md 自身が hook_boundaries_manifest_v1 を「機械可読な正本」と定義し、scripts/check_hook_boundaries.py が .claude/settings.json と構造照合すると宣言しています。ところがその manifest は現在も local_main_branch_guard と worktree_scope_guard を active PreToolUse blocker として登録し、さらに secret → local_main → worktree という順序まで記述しています。

    一方 #2262 の AC3 は、後段の「PreToolUse hook 実行順序」節の prose を直すだけです。

    これでは 同じドキュメント内で prose は「未wired」、machine-readable SSOT は「wired」のままになります。

    さらに既存 tests/test_hook_boundaries_doc.py は、この2件の drift を既知例外として明示的に期待しています。manifest を正しく直すと、このテストの期待値も変更が必要です。ところが tests/test_hook_boundaries_doc.py は #2262 の Allowed Paths 外です。

    つまり現契約では、

    Outcomeを本当に満たす → manifestを修正 → test修正が必要 → Allowed Paths違反 → Stop Condition

    という自己矛盾があります。

    P0-3 — repository-wide sweep で既に確定している漏れが Allowed Paths 外

    .codex/hooks/local_main_branch_guard.sh は現在も、

    Invoked by .codex/hooks.json hooks.PreToolUse and hooks.PermissionRequest.

    と明記しています。

    しかし current .codex/hooks.json は SessionEnd / SubagentStop の passive recorder だけです。

    これは #2262 が探している stale wiring claim そのものですが、Allowed Paths は .claude/hooks/local_main_branch_guard.sh、.codex/rules/default.rules、docs/dev/hook-boundaries.md の3ファイルしかありません。

    したがって「grep して見つかったら同一方針で修正」と「Allowed Paths外なら停止」が、既に実在する1ファイルによって衝突しています。

    最低でも .codex/hooks/local_main_branch_guard.sh を Allowed Paths に追加すべきです。

    P1 — 「PreToolUse hook 実行順序」という概念そのものが Claude Code 仕様と不整合

    ここは単なる stale list 更新では不十分です。

    Claude Code の現行公式仕様では、同一イベントで match した hooks は parallel に実行されます。また複数hookが inputを書き換える場合、完了順で結果が決まり、順序は non-deterministic と明記されています。(Claude)

    したがって、

    secret_boundary_guard → local_main_branch_guard → worktree_scope_guard

    という旧記述だけでなく、「PreToolUse hook 実行順序」という節名・モデル自体を廃止すべきです。

    「project settings に宣言されている PreToolUse handlers」程度の表現に変え、siblings 間に serial order を主張しないのが正しいです。

    P1 — AC1 が「別の未証明claim」への置換を要求している

    AC1 は stale な .claude/settings.json invocation claim を、

    「PreToolUse wiring は存在せず、呼び出しは Agent/Skill 側の behavioral contract に基づく」

    へ置き換えるとしています。

    しかし repository search で .claude/hooks/local_main_branch_guard.sh の具体的な callsite を追うと、現在確認できるのは docs、shared Python core の説明、test 等で、Agent/Skill がこの shell wrapper を production invocation している証拠は確認できません。

    PR #2256 が確立したのは workflow authority が behavioral contract 側にあるという話であって、その behavioral contract が shell wrapper を実行しているという話ではありません。

    したがって安全な表現は、

    wrapper は repo に残存するが、repo-controlled project .claude/settings.json からは登録されていない。
    workflow policy の authority と wrapper の runtime invocation は別概念である。

    です。

    「wiring」を「behavioral invocation」という別の推測に置換してはいけません。

    P1 — AC5 の Verification Command が AC5 を検証していない

    AC5 は PreToolUse hook、wired in、Invoked by .claude/settings.json 等を repository-wide に確認すると要求しています。しかし実際の VC は、

    rg -n "PreToolUse hook" --glob "!node_modules" .

    だけです。

    これでは、実際に今回見つかった .codex/hooks/local_main_branch_guard.sh の Invoked by .codex/hooks.json hooks.PreToolUse ... すら取り逃がします。

    また単純な「全件0件」も適切ではありません。historical note や「現在は未wired」と明示する正しい記述までヒットするためです。matchを列挙して active claim / historical / explicit-negative / stale に分類する方が堅牢です。

    P1 — project config と effective runtime を分離すべき

    Claude Code 公式仕様では hook source は .claude/settings.json だけではなく、user settings、local settings、managed policy、plugin、Skill/Agent frontmatter も存在します。(Claude)

    Codex upstream 実装も config layer stack を低→高の複数layerで discovery し、plugin hook source も追加します。 PreToolUse 自体も upstream runtime に実装されています。

    さらに2026年の Codex では、正しい .codex/hooks.json を置いても codex exec がhookをdispatchしないという未解決報告が複数あります。([GitHub]2)

    したがって #2262 は、

    「effective runtime では動いていない」

    ではなく、

    「repo-controlled project configuration には宣言されていない」

    までに限定すべきです。これは #2193 / PR #2256 が慎重に維持していた区別でもあります。

    P2 — Codex validator に dormant な旧topology expectation が残る

    check_hook_boundaries.py は #1830 の quarantine 方針を反映し、Codex PreToolUse の期待値を空 {} にしています。

    しかし scripts/check_codex_agent_config.py には旧来の複数 PreToolUse hook を列挙した EXPECTED_PRETOOL_HOOKS が残っています。 コード検索ではこの定数は同ファイルの定義以外に参照が見当たらず、即時runtime blockerとは評価しませんが、「repository-wide topology drift cleanup」を名乗るなら境界を明示すべきです。

    推奨する #2262 の修正方針

    #1830 は Codex enforcing PreToolUse / PermissionRequest を quarantine し passive recorder のみを active allowlist にしています。 #1860 と #1732 も Hook を authority/security boundary に戻さない minimal-harness 方針です。

    したがって hook再有効化はせず、現在の宣言状態との同期だけを行うべきです。Issue契約は概ね次まで直せば実装可能になります。

    verdict: REQUEST_CHANGES
    
    required_contract_changes:
      outcome:
        - ".claude/settings.json の project PreToolUse に
           local_main_branch_guard / worktree_scope_guard が存在しないことを authority にする"
        - "PreToolUse handler 数や 'secret_boundary_guard のみ' を prose に固定しない"
        - "project configuration と effective runtime を区別する"
    
      allowed_paths_add:
        - ".codex/hooks/local_main_branch_guard.sh"
        - "tests/test_hook_boundaries_doc.py"
    
      docs:
        - "hook_boundaries_manifest_v1 から inactive 2 guards の active entries を除去"
        - "固定 hook order の主張を除去"
        - "'実行順序' を 'configured handlers' 相当へ変更"
    
      ac1:
        - "Agent/Skill が wrapper を呼ぶ、とは未証明なので主張しない"
        - "wrapper existence / project wiring / workflow authority を分離する"
    
      ac5:
        - "PreToolUse hook だけでなく wired in / Invoked by .claude /
           Invoked by .codex / hooks.PreToolUse / hooks.PermissionRequest を走査"
        - "hit を zero-match ではなく意味分類して stale claim=0 を確認"
    
      verification:
        - "uv run --locked python3 scripts/check_hook_boundaries.py"
        - "uv run --locked pytest tests/test_hook_boundaries_doc.py -q"
        - "repository-wide causal-claim inventory"

    scripts/check_codex_agent_config.py の dormant EXPECTED_PRETOOL_HOOKS まで今回消すかは設計判断です。「repository-wide semantic topology cleanup」までやるなら Allowed Paths に追加、narrative claim 限定なら明示的に Out of Scope + follow-up が妥当です。

    最終評価は P0 blocker 3件、P1 blocker 4件、P2 follow-up 1件。特に hook_boundaries_manifest_v1 と tests/test_hook_boundaries_doc.py の漏れを直さずに PR を作ると、「stale topology を直すPRなのに機械可読SSOTは stale のまま」という状態になるため、ここはマージ阻止対象です。

    #2262 の本文や対応PRが更新された段階で、current-head に対して再レビューできます。

  4. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    OWNER レビューコメント(#2262 (comment)、VERDICT: REQUEST_CHANGES)の指摘事項を反映し、review-issue の再レビューで VERDICT: approve に到達しました。

    実施した本文改訂(3 iteration)

    1. Outcome の negative invariant 化: .claude/settings.json の PreToolUse cardinality(secret_boundary_guard のみ)を prose に固定する記述を廃止し、「local_main_branch_guard / worktree_scope_guard が存在しないこと」を authority とする negative invariant に変更。project configuration(宣言)と effective runtime(実行)を区別する表現を追加。
    2. Allowed Paths 拡張: .codex/hooks/local_main_branch_guard.sh(.codex/hooks.json への stale wiring claim が残存)と tests/test_hook_boundaries_doc.py(hook_boundaries_manifest_v1 修正に追随する既存テスト期待値更新)を追加。
    3. hook_boundaries_manifest_v1 修正を AC6 として新設: docs/dev/hook-boundaries.md 内の機械可読 SSOT から active PreToolUse entry と固定実行順序の主張を除去する対象を明記。
    4. AC7 新設: .codex/hooks/local_main_branch_guard.sh の stale claim(Invoked by .codex/hooks.json hooks.PreToolUse and hooks.PermissionRequest.)修正を追加。
    5. AC1 の書き直し: 「Agent/Skill が wrapper を呼ぶ」という未証明の代替 claim を主張しないよう、wrapper existence / project wiring / workflow authority を明確に分離した記述に変更。
    6. AC5 の Verification Command 強化: PreToolUse hook 単一キーワードの粗い rg から wired in / Invoked by .claude / Invoked by .codex / hooks.PreToolUse / hooks.PermissionRequest を含む複数キーワード走査へ拡張し、対象を Allowed Paths 内の具体ファイルへ narrow(VC preflight の broad-path blocker解消)。uv run --locked pytest tests/test_hook_boundaries_doc.py -q を追加。
    7. Out of Scope 明記: scripts/check_codex_agent_config.py の dormant EXPECTED_PRETOOL_HOOKS は P2 follow-up 扱いとし対象外、hook 再有効化は行わない旨を追記。
    8. VC preflight 起因の機械的修正(baseline-expect: pass 注釈追加、broad search path の narrow化、VC preflight allowlist外コマンドの除去)を 2 iteration かけて実施。

    Review 経過

    iteration VERDICT blockers
    1 needs-fix 7(VCフォーマット: missing_annotation x5, broad path, allowlist外コマンド)
    2 needs-fix 1(AC5統合コマンドの broad path)
    3 needs-fix 1(AC5統合コマンドの missing_annotation)
    4 approve 0

    最終 REVIEWED_BODY_SHA256: sha256:dcaad4fc7271a75a9d3559e027c8f9355dbc71314afc0a69698aa77f59a3bead

    Final Gate: not applicable(本ループは Issue 本文品質の refinement のみを担当。issue-contract-review は本ループのスコープ外であり未実行のため、contract_review.gate_result: missing_go)

    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: missing_go
        latest_comment_url: ""
        generated_at: "2026-08-20T10:12:49Z"
        body_sha256: "sha256:dcaad4fc7271a75a9d3559e027c8f9355dbc71314afc0a69698aa77f59a3bead"
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "label mutation not attempted in this run"
      auto_fixes:
        result: applied
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-08-20T10:12:49Z"
      checked_body_sha256: "sha256:dcaad4fc7271a75a9d3559e027c8f9355dbc71314afc0a69698aa77f59a3bead"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    次のアクション: issue-contract-review を実行して CONTRACT_REVIEW_RESULT_V1.status: go を取得後、impl-review-loop へ handoff してください。

  5. self-assigned this
    on Aug 20, 2026
  6. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-20T10:28:05Z)

  7. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 2 result(PR #2268 / head e4c687e)

    CI job codex-execpolicy の失敗(test_ac15_hook_boundaries_doc_has_5class_vocabulary)を修正した。

    Root cause

    AC6 修正で hook_boundaries_manifest_v1 の local_main_branch_guard PreToolUse entry を削除した際、同一 YAML ブロック内に同居していた無関係な「gh CLI コマンド 5 分類(#1124)」テーブルと github_issue_mutation_command / readonly_artifact_export_command の allow 条件 2 節も、ブロックごと丸ごと巻き込まれて削除されていた。この分類テーブルは PreToolUse wiring の主張ではなく、guard 内部の gh コマンド分類ロジックを記述するものであり、削除対象ではなかった。

    修正内容

    docs/dev/hook-boundaries.md の「## 3. agent 判断表(Claude Code / Claude Code 向け)」節末尾に、以下を復元した:

    • ### local_main_branch_guard の gh CLI コマンド 5 分類(#1124) テーブル
    • ### github_issue_mutation_command の allow 条件
    • ### readonly_artifact_export_command の allow 条件

    「project PreToolUse に現在登録されていない」という AC6 の主張は維持したまま、この分類テーブルは「project PreToolUse 登録の有無とは独立した guard 内部の behavioral contract」として明示的に reframe した(該当ブロック冒頭に一文追加)。hook_boundaries_manifest_v1 の active PreToolUse entry 自体は再導入していない。docs/dev/agent-skill-boundaries.md は Allowed Paths 外のため変更していない。

    Verification(再実行結果)

    $ rg -n "Invoked by \.claude/settings\.json PreToolUse hook" .claude/hooks/local_main_branch_guard.sh
    exit=1(マッチなし = pass)
    
    $ rg -n "wired in \.codex/hooks\.json" .codex/rules/default.rules
    exit=1(マッチなし = pass)
    
    $ rg -n "PreToolUse hook 実行順序" docs/dev/hook-boundaries.md
    exit=1(マッチなし = pass)
    
    $ rg -n "local_main_branch_guard\.sh.*エントリ" docs/dev/hook-boundaries.md
    exit=1(マッチなし = pass)
    
    $ rg -n "Invoked by \.codex/hooks\.json hooks\.PreToolUse" .codex/hooks/local_main_branch_guard.sh
    exit=1(マッチなし = pass)
    
    $ 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
    exit=0、1件(hook-boundaries.md:545、pretool_fastpath_classifier.py 節。既に explicit-negative として分類済みの既存箇所、変更なし)
    
    $ uv run --locked pytest tests/test_hook_boundaries_doc.py -q
    33 passed
    
    $ uv run --locked pytest tests/codex/test_local_main_branch_guard.py -q
    308 passed(今回失敗していた test_ac15_hook_boundaries_doc_has_5class_vocabulary を含む)
    
    $ uv run --locked pytest scripts/ci/tests/test_codex_execpolicy_matrix.py tests/codex/test_execpolicy_matrix.py -q
    17 passed
    

    git diff --stat: docs/dev/hook-boundaries.md | 36 ++++++++++++++++++++++++++++++++++++(Allowed Paths 内、1ファイルのみ)。

    Commit: e4c687e、push 済み(worktree-issue-2262-stale-hook-wiring-claims)。PR #2268 head 更新。CI 再実行待ち。

  8. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 3 対応完了

    CI python-test-core の 4 件の失敗(head e4c687e 時点)を修正し、PR #2268 に push 済み(新 head 2da1086e)。

    修正内容

    1. tests/agent_ops/test_probe_docs_contract.py::TestPolicyAlignment::test_policy_alignment_hook_boundaries_probe_scripts_in_allowlist
      docs/dev/hook-boundaries.md の gh CLI 5分類節に、probe scripts(git_ref_probe.py / git_worktree_probe.py)が DETERMINISTIC_CHECKER_ALLOWLIST に登録済みである旨(実装: git ref/worktree probe を script 化し、shell quoting と compound command 起因の迷走を削減する #1197)の記述を復元。AC6 の manifest entry 削除で失われていたが、PreToolUse 未登録の behavioral contract として独立した節に記述し、stale wiring claim は再導入していない。

    2. check_hook_boundaries.py drift が旧 調査: PreToolUse hook chain(local_main_branch_guard/worktree_scope_guard)の繰り返し誤ブロックを踏まえ無効化・縮小・現状維持の方針を決定する #1690 既知 2 件 → 空集合へ変化
      AC6 で manifest entry を削除した意図どおりの結果。以下の既存テストがこの空集合の drift を反映するよう更新:

      • .claude/hooks/tests/test_generate_session_manifest_from_hook.py::test_hook_boundaries_sync
      • .claude/hooks/tests/test_local_main_branch_guard.py::TestAC7HookBoundariesManifest::test_check_hook_boundaries_passes
      • scripts/agent-guards/tests/test_local_main_branch_guard.py(上記の shim エントリポイントのため実体変更なし)

    Scope Delta

    上記 3 ファイルを Allowed Paths に追加済み(Issue 本文の ## Scope Delta セクション参照)。

    検証結果(全 PASS)

    uv run --locked pytest tests/agent_ops/test_probe_docs_contract.py -q         # 6 passed
    uv run --locked pytest .claude/hooks/tests/test_generate_session_manifest_from_hook.py \
      .claude/hooks/tests/test_local_main_branch_guard.py -q                       # 379 passed
    uv run --locked pytest scripts/agent-guards/tests/test_local_main_branch_guard.py -q  # 374 passed
    uv run --locked pytest tests/test_hook_boundaries_doc.py -q                    # 33 passed
    uv run --locked pytest tests/codex/test_local_main_branch_guard.py -q          # included in combined 347 passed run
    

    AC1-AC4, AC7 rg checks: 全て exit 1(マッチなし、修正後の期待どおり)。
    AC5 repository-wide grep: 既存の explicit-negative 1件(pretool_fastpath_classifier.py 節)のみで新規 stale claim なし(iteration 1/2 時点の分類から変化なし)。

    PR: #2268

  9. squne121 commented on Aug 20, 2026

    @squne121
    OwnerAuthor

    fix_delta iteration 4 完了

    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 させていた。

    見出しへ日本語プロース「登録範囲」を追加し(### deterministic_checker_command と probe scripts の登録範囲(#1197))、
    validate_japanese_content.py --file docs/dev/hook-boundaries.md --threshold 0.1 をローカル再実行して
    docs/dev/hook-boundaries.md 単体で PASS(exit 0)を確認した。identifiers(deterministic_checker_command /
    probe scripts / #1197)の意味は変更していない。

    再検証結果

    • AC1-AC4, AC7 grep(stale wiring claim 不在): 全て exit 1(マッチなし = PASS)
    • AC6: uv run --locked pytest tests/test_hook_boundaries_doc.py -q -> 33 passed
    • 回帰確認: tests/codex/test_local_main_branch_guard.py tests/agent_ops/test_probe_docs_contract.py
      .claude/hooks/tests/test_generate_session_manifest_from_hook.py .claude/hooks/tests/test_local_main_branch_guard.py
      scripts/agent-guards/tests/test_local_main_branch_guard.py -> 1067 passed
    • git diff --stat: docs/dev/hook-boundaries.md | 2 +-(1 ファイルのみ、Allowed Paths 内)

    Commit: c3d98fe
    Branch: worktree-issue-2262-stale-hook-wiring-claims
    PR: #2268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions