Skip to content

実装: PreToolUse hook の read-only / exact-executor fast-path と telemetry dedupe を追加する #1289

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PreToolUse hook に read-only / exact-executor fast-path と telemetry dedupe を追加し、read-only 操作の hook ノイズを削減する"
change_kind: mixed

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: 既に allowlist で read-only と判定される操作の hook 出力・重複検査を減らす(security relaxation はしない)
  • Desired Destination: mutating / unknown command は既存 fail-closed chain のまま、read-only と exact controlled executor だけが fast-path を通る状態

Current Validated Scope

  • scripts/agent-guards/pretool_fastpath_classifier.py(新規)で readonly_display / exact_controlled_executor / mutation_or_unknown を早期分類
  • classifier は独立 PreToolUse hook として追加せず、既存 guard(local_main_branch_guard / worktree_scope_guard)から共有ライブラリとして import される
  • hook boundary manifest(.codex/hooks.json を含む)への classification / fail policy / stdout-stderr contract 追記
  • classifier テスト追加

Remaining Parent Gaps

  • controlled executor command id の拡張(issue metadata mutation)は別 Issue で扱う
  • hook 実行時間の CI ベンチ常設化は、budget 検証の結果を見て follow-up 判断

Outcome

pretool_fastpath_classifier.py が read-only command / exact controlled executor / mutation_or_unknown を決定論的に分類し、read-only 操作では冗長な hook status message が dedupe され、mutating / unknown は既存 fail-closed hook chain を無変更で通過し、分類・fail policy が manifest とテストで固定された状態。

Background

.codex/hooks.json では Bash の PreToolUse に local main guard、worktree guard、agent guardrail、session recording、CI/test advisory が連鎖し、read-only 操作でも複数 hook の status 出力が transcript に露出する。hook boundary docs は、non-blocking の hook failure でも transcript に露出して agent 判断を汚染し得ると明記している。worktree_scope_guard.py は read-only を worktree unresolved でも allow する分類を既に持つため、fast-path はこの既存分類を明示的に再利用し、新たな allow を作らない。

classifier は既存 hook の内部で呼び出される共有 module として実装し、.claude/settings.json / .codex/hooks.json に独立 PreToolUse hook として登録しない(hook topology を増やさない)。read-only 判定は、local_main_branch_guard と worktree_scope_guard の両方が read-only と判定する交差集合(intersection)のみを readonly_display とし、片方でも unknown / mutating / cleanup / metadata mutation と判定する場合は mutation_or_unknown とする。

gh api は method・field flag・endpoint を token-level で検証し、default POST 化する flag が存在する場合は mutation_or_unknown とする。gh issue / gh pr の --web / -w は browser side effect を持つため readonly_display から除外する。

分類語彙として exact_controlled_executor_shape(canonical executor path + exact argv shape のみに一致)と exact_controlled_executor_authorized(shape に加え command_id が ALL_COMMAND_IDS に属し、repo binding・input namespace shape・stable policy_hash が計算可能であることを満たす)を区別する。この条件を満たさない controlled executor lookalike は mutation_or_unknown に分類する。fast-path と telemetry dedupe の根拠にできるのは exact_controlled_executor_authorized のみとする。

local_main_branch_guard.py の controlled skill mutation executor allow は現在 REASON_DETERMINISTIC_CHECKER を返しているが、telemetry hash logging の歪みを防ぐため独立 reason_code controlled_skill_mutation_executor に分離する。

In Scope

  • pretool_fastpath_classifier.py 新規追加。readonly_display(gh issue view / gh issue list / gh pr view / git status / git diff / rg 等、--web/-w を除く)、exact_controlled_executor_authorized(skill_runtime_exec.py / controlled_skill_mutation_exec.py の exact 呼び出し)、mutation_or_unknown(既存 chain 無変更、exact_controlled_executor_shape のみで authorized 条件を満たさないものを含む)の 3 分類
  • read-only 判定は local_main_branch_guard と worktree_scope_guard の交差集合として計算する(片方でも unknown/mutating/cleanup/metadata mutation なら mutation_or_unknown)
  • gh api の method / field flag / endpoint token-level 検証(POST 化 flag 存在時は mutation_or_unknown)
  • read-only 分類時の telemetry dedupe(bounded fast-path summary のみ)
  • exact_controlled_executor_authorized 分類時の registry/policy hash 記録(raw command body / secret-like value を出さない)
  • local_main_branch_guard.py の controlled skill mutation executor allow reason を controlled_skill_mutation_executor として独立させる
  • hook boundary manifest(docs/dev/hook-boundaries.md)と scripts/check_hook_boundaries.py の検証対象に .codex/hooks.json を追加し、fast-path 契約を追記
  • classifier テスト(must-fastpath / must-not-fastpath 両軸)追加と .github/ci/python-test-plan.json 登録

Out of Scope

  • 既存 fail-closed guard(local_main_branch_guard / worktree_scope_guard)の判定緩和
  • mutating command の分類変更
  • controlled executor の command id 追加
  • 独立 PreToolUse hook としての classifier 登録(hook topology 追加)

Acceptance Criteria

  • AC1: read-only command(gh issue view / git status / rg)は readonly_display に分類され、bounded fast-path summary のみを残す
  • AC2: mutating / unknown command は mutation_or_unknown に分類され、既存 fail-closed hook chain を無変更で通る
  • AC3: exact_controlled_executor_authorized 呼び出しは registry/policy hash を記録し、raw command body や secret-like value を transcript 出力に含めない。exact_controlled_executor_shape のみで authorized 条件を満たさない呼び出しは mutation_or_unknown に分類される
  • AC4: hook boundary manifest(.codex/hooks.json を含む)に fast-path の classification / fail policy / stdout-stderr contract が記載されている
  • AC5: read-only command の classifier 実行時間がテストで設定した budget 以下である
  • AC6: classifier は独立 PreToolUse hook として登録されず、.claude/settings.json / .codex/hooks.json の hook 数(topology)が本変更前後で変わらないことを check_hook_boundaries.py で検証できる
  • AC7: readonly_display は local_main_branch_guard と worktree_scope_guard の交差集合のみに分類され、片方でも unknown/mutating/cleanup/metadata mutation と判定するケースは mutation_or_unknown に分類される。gh api は POST 化 flag 存在時に mutation_or_unknown、gh issue/gh pr の --web/-w は readonly_display から除外される
  • AC8: local_main_branch_guard.py の controlled skill mutation executor allow が独立 reason_code controlled_skill_mutation_executor を返す

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac1_readonly_display_bounded_summary -q
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac2_mutation_or_unknown_existing_chain_unchanged -q
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac3_exact_executor_hash_no_raw_body -q
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac4_hook_boundary_manifest_fastpath_contract -q
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac5_readonly_classification_within_budget -q
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac6_no_new_hook_topology -q
# AC7
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac7_readonly_intersection_and_gh_api_token_check -q
# AC8
$ uv run --locked pytest scripts/agent-guards/tests/test_pretool_fastpath_classifier.py -k test_ac8_controlled_skill_mutation_executor_reason_code -q

Runtime Verification Applicability

  • decision: immediate
    applicable_acs: AC1, AC2, AC3, AC4, AC5, AC6, AC7, AC8
    execution_environment: repo checkout worktree(uv run --locked pytest が利用可能な環境)
    skip_conditions: 実装前(scripts/agent-guards/pretool_fastpath_classifier.py と scripts/agent-guards/tests/test_pretool_fastpath_classifier.py が未作成)の段階では file-not-found による baseline fail(expected baseline fail)を許容する。実装後は SKIP しない。
    fallback_policy: baseline fail を弱める/AC・VC を緩めることは禁止する。実装後も VC が fail する場合は Stop Condition として扱う。
    artifact_requirements: uv run --locked pytest の stdout/exit code を実行証跡として保存する
  • AC1〜AC8 の VC はいずれも未作成の specific test file(scripts/agent-guards/tests/test_pretool_fastpath_classifier.py)を参照する uv run --locked pytest 呼び出しであり、実装前は file-not-found による baseline fail(expected baseline fail)を返す。
  • 実装 PR で classifier とテストファイルが作成された時点で、同一 VC が実行可能になり pass/fail を判定できるため deferred/not_applicable ではない。
  • baseline fail は本文の欠陥を示すものではなく、実装前段階として想定された状態である。

Allowed Paths

  • scripts/agent-guards/pretool_fastpath_classifier.py
  • scripts/agent-guards/tests/test_pretool_fastpath_classifier.py
  • scripts/agent-guards/local_main_branch_guard.py
  • .claude/hooks/worktree_scope_guard.py
  • .claude/hooks/tests/test_local_main_branch_guard.py
  • tests/codex/test_local_main_branch_guard.py
  • scripts/check_hook_boundaries.py
  • .codex/hooks.json
  • .claude/settings.json
  • docs/dev/hook-boundaries.md
  • .github/ci/python-test-plan.json

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Delta(任意)

N/A

Dependencies / Precondition

Notes for Reviewer

  • 本 Issue は security relaxation ではない。fast-path は既存 allowlist の read-only 分類を再利用するのみで、新規 allow を導入しない
  • fail-closed guard の変更を含むため、must-block / must-allow 両軸の adversarial テストを必須とする
  • timing テスト(budget 検証)は parallel 実行と干渉しないよう serial lane 分離を検討する
  • tests/codex/test_local_main_branch_guard.py は Allowed Paths に追加する。fix: raw issue metadata mutation を controlled executor に一本化 #1298(raw issue metadata mutation の controlled executor 一本化)が main へマージされたことで本 PR とのマージ時に AC8 の reason_code 分離(REASON_DETERMINISTIC_CHECKER → REASON_CONTROLLED_SKILL_MUTATION_EXECUTOR)を前提としない古い assertion が同ファイルの Codex flavor テストにも存在することが判明した。.claude/hooks/tests/test_local_main_branch_guard.py と同じ AC8 帰結のassertion 1 箇所(controlled_skill_mutation_exec.py 呼び出しの reason_code 期待値)のみを更新する変更に限定する
  • worktree scope guard の実体ファイルは .claude/hooks/worktree_scope_guard.py であり(scripts/agent-guards/ 配下には存在しない)、Allowed Paths はこの実パスを指す
  • AC8 の reason_code 分離(REASON_DETERMINISTIC_CHECKER → controlled_skill_mutation_executor)に伴い、.claude/hooks/tests/test_local_main_branch_guard.py 内で controlled_skill_mutation_exec の allow が REASON_DETERMINISTIC_CHECKER を返すことを検証している既存 assertion(1 箇所)を新 reason_code に更新する。これは AC8 が意図する contract 変更の直接帰結であり、既存テストの大規模改変には該当しない
  • Allowed Paths / AC 中の python-test-plan 参照は .github/ci/python-test-plan.json が正本であり scripts/python-test-plan.json は存在しない(誤記修正済み)

Activity

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

    @squne121
    OwnerAuthor

    総合判定

    Issue #1289 の方向性自体は妥当です。PreToolUse の read-only 系コマンドで毎回重い guard と status 出力が走るのは運用ノイズです。ただし、現 Issue 本文のまま実装すると、fast-path が「ノイズ削減」ではなく「既存 fail-closed hook chain の実質的な迂回」になる危険が高いです。

    特に致命的なのは、Issue が「read-only / exact-executor fast-path」と言っている一方で、現在のリポジトリには local_main_branch_guard.py、worktree_scope_guard.py、controlled executor policy、Claude hook topology、Codex hook topology の間で判定責務が分散しており、どの判定を SSOT として fast-path 化するのかが固定されていない点です。

    Issue #1289 自体はコメント 0 件で、追加の人間補足はありません。 直前の親文脈に近い Issue #1284 は、metadata mutation を controlled executor lane に移す設計で、#1289 を「PreToolUse hook chain の read-only fast-path / telemetry dedupe 最適化」として明示的に別スコープへ分離しています。 さらに #1291 では raw gh issue edit/comment allowlist を controlled executor lane へ一本化する follow-up が立っており、#1289 の fast-path はこの移行中の二重認可状態を踏み抜く可能性があります。

    Blocker 1: 「fast-path が何を skip するのか」が未定義

    Claude Code hooks の公式仕様では、tool event は matcher と if で handler 起動を絞り込むモデルです。if がマッチしなければ handler を spawn しない一方、if なしでは matched group 内の handler が走る、という説明になっています。([Claude Platform Docs]1) また、PreToolUse の JSON decision control は hookSpecificOutput.permissionDecision の allow/deny/ask/defer などであり、既存の後続 hook handler を条件付きで「まとめて skip する」ための明示 API としては説明されていません。([Claude Platform Docs]1)

    リポジトリ側を見ると、Claude の .claude/settings.json では PreToolUse に secret_boundary_guard、local_main_branch_guard、worktree_scope_guard、guard-japanese-prose、rtk_boundary_shadow_guard、ci_test_performance_advisory が並んでいます。 Codex 側の .codex/hooks.json も Bash PreToolUse に複数 hook を持ち、各 hook に statusMessage が設定されています。

    したがって、pretool_fastpath_classifier.py を先頭に足すだけでは、むしろ hook が 1 個増えてノイズが増える可能性があります。Issue #1289 には、少なくとも次のいずれかを AC に追加すべきです。

    1. hook 設定レベルの if 条件で read-only command では重い handler を spawn しない。
    2. classifier が machine-readable な decision artifact を出し、それを後続 hook が明示的に読んで self-skip する。
    3. 既存 hook 内に fast-path を組み込み、topology は増やさない。

    現状の Issue 本文はこの選択をしていないため、実装者が「fast-path summary を出すだけ」の実装をしても AC を満たしたように見えてしまいます。これは merge blocker です。

    Blocker 2: read-only 判定が既に split-brain している

    local_main_branch_guard.py の read-only allowlist は広く、rg、grep、git status/log/show/diff/...、git branch --show-current、git ls-files、git worktree list、gh issue view/list、gh pr view/list/status を read-only として扱います。 一方、worktree_scope_guard.py の _classify_gh は gh issue view と gh pr view は read-only にしますが、gh issue list や gh pr list/status は同じ扱いではありません。

    逆方向のズレもあります。worktree_scope_guard.py は gh api を GET default / 明示 GET / field flag の有無で分類し、default GET や explicit GET without field を read-only とみなします。 しかし local_main_branch_guard.py 側は gh api を issue comment endpoint の GET にほぼ限定して allow しています。 GitHub CLI 公式 manual でも gh api は通常 GET ですが、field parameter を付けると POST に切り替わるとされており、ここは token-level に閉じた分類が必要です。(GitHub CLI)

    Issue #1289 が「既存 allowlist で read-only」と言うなら、どの allowlist かを固定しなければなりません。敵対的には、実装者が local_main_branch_guard.is_readonly_command() をそのまま使い、worktree_scope_guard が unknown と扱う command を fast-path skip してしまう実装が成立します。

    推奨 AC は次です。

    AC追加案:
    - readonly_display は local_main_branch_guard と worktree_scope_guard の両方が read-only と判定する交差集合のみ。
    - 片方でも unknown / mutating / cleanup / metadata mutation と判定する場合は mutation_or_unknown。
    - gh api は method・field flag・endpoint を token-level で検証し、default POST 化する flag が存在する場合は mutation_or_unknown。
    - gh issue/pr の --web/-w は browser side effect として readonly_display から除外。
    

    gh issue view --web は公式 manual 上もブラウザを開く動作です。([GitHub CLI]3) gh issue list --web も browser 表示です。([GitHub CLI]4) これは read-only display ではなく side-effectful / interactive として扱うべきです。

    Blocker 3: exact controlled executor 判定が「argv 形状のみ」なので、fast-path の根拠として弱い

    controlled_skill_mutation_policy.py は shared policy として worktree_scope_guard.py と local_main_branch_guard.py から使われる設計です。 ただし is_controlled_skill_mutation_exec_command() は、executor script の canonical path と argv shape を検証する関数で、semantic constraints は executor 側で enforce するという設計になっています。 実際、executor 本体は args.command_id not in ALL_COMMAND_IDS を runtime validation で拒否します。

    これは通常の guard allow としては成立します。executor 自体が fail-closed するからです。しかし #1289 の classifier がこの関数だけを根拠に exact_controlled_executor と分類し、後続 telemetry や guard を skip / dedupe するなら、未知の --command-id も「exact executor」として扱われる余地があります。PR #1295 の説明でも、新 3 command id は「executor script identity + argv 形状のみを検証するため、追加 allowlist entry なしで同じ allow 経路に乗る」と説明されています。

    #1289 の AC3 は「exact controlled executor logs registry/policy hash」としていますが、現在の controlled mutation lane は registry というより Python dict policy が中心です。skill_runtime_exec.py 側には registry load / registry validation がありますが、controlled metadata executor 側は CONTROLLED_SKILL_MUTATION_COMMAND_POLICY と executor validation が中心です。

    したがって分類語彙を分けるべきです。

    exact_controlled_executor_shape
      = canonical executor path + exact argv shape only
    
    exact_controlled_executor_authorized
      = shape + command_id ∈ ALL_COMMAND_IDS + repo binding + input namespace shape
        + stable policy_hash computable
    
    mutation_or_unknown
      = aboveを満たさない controlled executor lookalike
    

    また、local_main_branch_guard.py では controlled skill mutation executor を allow する箇所が、reason として REASON_DETERMINISTIC_CHECKER を返しています。 #1289 が telemetry dedupe をするなら、ここは controlled_skill_mutation_executor の独立 reason_code に直さないと、hash logging と分類結果が歪みます。

    Blocker 4: hook boundary manifest と validator の対象が Claude 側だけ

    docs/dev/hook-boundaries.md は .claude/settings.json hook topology の SSOT として書かれており、scripts/check_hook_boundaries.py が manifest と .claude/settings.json を構造照合する設計です。 実装も DOCS_PATH = docs/dev/hook-boundaries.md、SETTINGS_PATH = .claude/settings.json に固定されています。

    一方 #1289 は .codex/hooks.json と .claude/settings.json の両方を wire 対象にしています。Codex 側の topology はこの manifest checker の照合対象ではありません。さらに validator の classification vocabulary は blocker, telemetry, warning, mode_dependent に固定されています。 新たに fast_path のような分類を足すなら validator 更新が必要ですが、#1289 の Allowed Paths には scripts/check_hook_boundaries.py が含まれていません。これは stop condition 相当です。

    対応案は二択です。

    • pretool_fastpath_classifier を既存 vocabulary の warning または telemetry として表現し、authorization ではないことを明記する。
    • manifest schema / checker を変更するため、Issue の Allowed Paths に scripts/check_hook_boundaries.py を追加する。

    後者を選ぶなら、Codex hook manifest の構造照合も新規に入れないと片手落ちです。

    Blocker 5: test plan の path が Issue 本文と実リポジトリで一致していない

    #1289 の Allowed Paths は scripts/python-test-plan.json を挙げていますが、リポジトリの実 SSOT は .github/ci/python-test-plan.json です。loader も DEFAULT_PLAN_PATH = .github/ci/python-test-plan.json に固定されています。 実際の plan は .github/ci/python-test-plan.json で、scripts/agent-guards/tests/ は既に target に含まれています。

    つまり、新規テストを scripts/agent-guards/tests/ に置くだけなら個別登録は不要です。逆に、AC5 の「execution time within test budget」を安定化するために serial lane / parallel_exclude を触るなら、実際に触るべきファイルは .github/ci/python-test-plan.json であり、現 Issue の Allowed Paths 外です。

    pytest-xdist は -n で複数 worker を使い、-n 0 で xdist を無効化できます。(pytest-xdist) 現 plan は workers 4 / loadscope / parallel_exclude: [] です。 wall-clock 性能を strict に測るテストを通常 lane に入れると flaky 化します。性能 AC は「subprocess を呼ばない純粋関数であること」「fixture 上の分類が O(tokens) であること」「統計的な wall-clock ではなく import 回数・subprocess 呼び出しゼロを検証すること」に寄せるべきです。

    Major: secret_boundary_guard を fast-path で迂回してはいけない

    Claude 側の最初の PreToolUse は secret_boundary_guard.sh で、matcher は Bash|Read|Write|Edit|Grep|Glob|MultiEdit です。 #1289 の例は Bash の gh issue view, git status, rg ですが、Issue が「PreToolUse hook」と広く言っているため、実装者が Read/Grep/Glob まで fast-path 対象に拡張する危険があります。

    これは明確に禁止すべきです。read-only display は「Bash command の中でも token-level に display-only と証明できるもの」だけに限定し、Read/Grep/Glob は secret boundary の対象として残すべきです。Bash の rg であっても、stdout に secret-like path/value が出る可能性はあります。少なくとも classifier の stdout/stderr は silent または bounded hash-only にすべきで、raw command、raw cwd、raw file path、raw transcript を出してはいけません。既存 manifest も blocker hook で no_raw_command, no_raw_secret_like_value, no_raw_transcript を要求しています。

    Major: telemetry dedupe の schema が必要

    「dedupe」と言うなら、dedupe key と出力契約が必要です。既存 manifest では local_main_branch_guard と worktree_scope_guard は allow 時 stdout silent です。 一方、ci_test_performance_advisory は Claude の hookSpecificOutput.additionalContext 形式で advisory を出す warning hook です。

    #1289 の classifier は、次のような固定 schema を持つべきです。

    PRETOOL_FASTPATH_DECISION_V1:
      decision: readonly_display | exact_controlled_executor_authorized | mutation_or_unknown
      chain_action: pass_through | self_skip_downstream_if_supported
      tool_name: Bash
      classifier_version: v1
      readonly_policy_hash: sha256:<canonical-json-or-source-hash>
      controlled_policy_hash: sha256:<canonical-json-or-source-hash> | null
      registry_hash: sha256:<canonical-json-or-source-hash> | null
      reason_code: bounded_string_enum
      raw_command_emitted: false
      raw_secret_like_value_emitted: false

    重要なのは、chain_action を入れることです。これがないと、「分類した」だけなのか「後続 hook を省いた」のかがレビュー不能になります。

    Major: related PR #1295 から見るべき教訓

    PR #1295 は #1284 の実装 PR で、controlled metadata executor lane の追加、raw gh issue edit/comment block 維持、stale-write/readback/postcondition を主張しています。 その PR コメントでは、検証レポートは PASS を出した一方、レビュー側は Allowed Paths gate failure と日本語 prose check failure を blocker として REQUEST_CHANGES にしています。

    #1289 でも同じ事故が起きる可能性が高いです。Issue 本文の Allowed Paths と実 SSOT がズレており、manifest checker の対象外で Codex hook を触ろうとしているからです。実装前に Issue contract を修正しないと、実装 PR 側で「Scope Delta 開示済みだが gate fail_closed」という状態になります。

    推奨する Issue #1289 の修正文

    この Issue は、実装前に少なくとも次の文言へ絞るべきです。

    Scope correction:
    - scripts/python-test-plan.json は存在しないため Allowed Paths から削除。
    - 新規 pytest が scripts/agent-guards/tests/ 配下だけなら .github/ci/python-test-plan.json は変更しない。
    - timing/serial lane 変更が必要な場合のみ .github/ci/python-test-plan.json を Allowed Paths に追加。
    
    Fast-path semantics:
    - fast-path は authorization ではない。
    - mutation_or_unknown は既存 PreToolUse fail-closed chain を完全に通す。
    - readonly_display は local_main_branch_guard と worktree_scope_guard の交差集合のみ。
    - exact_controlled_executor は shape-only と authorized を区別する。
    - unknown command-id / repo mismatch / input namespace mismatch は mutation_or_unknown。
    
    Hook topology:
    - Claude: secret_boundary_guard を skip しない。
    - Codex: .codex/hooks.json の statusMessage 増加を許容しない。classifier 追加で statusMessage が増える場合は失敗。
    - downstream skip を実現する場合は hook handler が読む machine-readable decision artifact を定義する。
    
    Manifest:
    - docs/dev/hook-boundaries.md に classifier の classification/fail_policy/stdout/stderr/redaction を追加。
    - classification vocabulary を増やすなら scripts/check_hook_boundaries.py も Allowed Paths に追加。
    - Codex parity を主張するなら Codex hook topology checker も追加する。
    
    Tests:
    - unit tests: token-level classifier for gh/git/rg, --web, gh api field flags, shell metachar, env prefix, redirection, pipeline.
    - integration tests: actual PreToolUse-shaped stdin through Claude hook wrappers where applicable.
    - negative tests: no raw command in stdout/stderr; mutation_or_unknown does not suppress existing blocker hooks.
    

    最終レビュー結論

    この Issue は Ready for implementation ではありません。
    現状のままなら、実装 PR は「fast-path の名で既存 guard の split-brain を固定化する」か、「classifier を追加しただけで telemetry dedupe できていない」かのどちらかになりやすいです。

    実装に進める最低条件は、次の 4 点です。

    1. fast-path の実行モデルを「分類だけ」「downstream self-skip」「hook topology の if 化」のどれかに固定する。
    2. read-only 判定を local_main_branch_guard と worktree_scope_guard の交差集合に限定する。
    3. controlled executor を shape-only と authorized に分け、unknown command-id を fast-path しない。
    4. scripts/python-test-plan.json という誤った Allowed Path を直し、必要なら .github/ci/python-test-plan.json と scripts/check_hook_boundaries.py を Allowed Paths に追加する。
  3. squne121 commented on Jul 2, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jul 2, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-02T23:06:37Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1289
      body_sha256: "sha256:cf4c1dfb1fccec17587348065f1ed95dc4eaf7df3e74897773ad3774e075dcfd"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  5. squne121 commented on Jul 2, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-02T23:17:48Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1289
      body_sha256: "sha256:530298d5b1dd1d2c6eba46212d589fca300bc5c7ab1fbf1437200ac5dc6a9356"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto

    前コメントの go(body_sha256: cf4c1dfb…)は Allowed Paths 訂正(worktree scope guard 実パス化・AC8 関連テストファイル追加)後の本文更新により supersede される。本コメントが最新の contract snapshot である。

  6. squne121 commented on Jul 2, 2026

    @squne121
    OwnerAuthor

    実装完了: PR #1299(Draft, MERGEABLE, head 6e07458)

    • scripts/agent-guards/pretool_fastpath_classifier.py 新規追加(readonly_display / exact_controlled_executor_authorized / mutation_or_unknown の 3 分類、独立 PreToolUse hook として非登録)
    • local_main_branch_guard.py Step 13.6 の controlled skill mutation executor allow を独立 reason_code controlled_skill_mutation_executor に分離(AC8)
    • docs/dev/hook-boundaries.md / .codex/hooks.json に fast-path contract を追記、check_hook_boundaries.py の検証対象に .codex/hooks.json を追加
    • scripts/agent-guards/tests/test_pretool_fastpath_classifier.py 新規追加(AC1〜AC8、must-fastpath / must-not-fastpath 両軸)
    • .claude/hooks/tests/test_local_main_branch_guard.py の既存 assertion 1 箇所のみ新 reason_code に更新(Notes for Reviewer 記載範囲)

    検証: AC1〜AC8 VC すべて PASS、scripts/agent-guards/tests/ + .claude/hooks/tests/ 686 件無破壊、check_hook_boundaries.py drift なし、pnpm typecheck/lint/test/build すべて green。

    Closes #1289

  7. squne121 commented on Jul 3, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-03T10:55:41Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1289
      body_sha256: "sha256:de9cbd3aa51caf388c5f14f54dd143e92617820b2b3c47fd0a12b8a563b69e91"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto

    Scope Delta: tests/codex/test_local_main_branch_guard.py を Allowed Paths に追加(#1298 マージ後の AC8 reason_code assertion 整合のため)。前コメント(body_sha256: 530298d5…)を supersede する。

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

Metadata

Metadata

Assignees

No one assigned

    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