Skip to content

実装: blocked Stop/SubagentStop attempt で標準 manifest を抑止する coordinator hook を導入する #651

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#433"
goal_ref: "blocked Stop/SubagentStop attempt では標準 agent_session_manifest を生成せず、guard と producer を単一 coordinator hook で直列化する(session manifest hook は best-effort telemetry であり AI agent 作業をブロックしない)"
change_kind: workflow

Parent Issue

#433

Parent Goal Ref

  • Goal: blocked Stop/SubagentStop attempt の manifest policy を設計文書に記録し、coordinator hook 実装の implementation Issue を起票する
  • Desired Destination: Stop / SubagentStop で guard verdict を producer より先に確定し、blocked attempt では標準 manifest を生成しない deterministic wiring へ移行する。ただし session manifest hook は best-effort telemetry であり、manifest 生成失敗で AI agent 作業をブロックしない。

Current Validated Scope

  • .claude/settings.json の Stop / SubagentStop wiring を sibling hooks から coordinator hook に置き換える
  • .claude/hooks/session_manifest_coordinator.sh を追加し、guard → producer の直列実行と exit code contract を実装する(coordinator は原則 exit 0 で fail-open)
  • .claude/hooks/tests/ に blocked attempt suppress / pass-through / stop_hook_active まわりの unit test を追加する
  • docs/dev/session-recording-policy.md を coordinator 実装 reality(best-effort telemetry, single coordinator only)に同期する

Remaining Parent Gaps

  • blocked attempt を監査記録として残す場合の agent_session_block/v1 スキーマ設計と producer 実装は別 Issue で扱う
  • Secret 境界の upstream 統制と scanner 強化は #412 側で扱う

Outcome

Stop / SubagentStop で coordinator hook が guard verdict を直列確定する。guard failure 時は標準 agent_session_manifest を生成せず coordinator は exit 0 で終了し(AI agent 作業を阻止しない)、対応テストと policy 文書が coordinator の best-effort テレメトリとしての位置付けに一致している状態。

In Scope

  • Stop / SubagentStop 用 coordinator hook の追加
  • .claude/settings.json の wiring 置換と sibling hook 解消
  • blocked attempt 時の標準 manifest 非生成テスト
  • guard pass 時の producer 実行継続テスト
  • stop_hook_active: true 時の short-circuit テスト(producer を呼ばず exit 0)
  • policy SSOT の実装 reality 同期(best-effort telemetry, single coordinator only)

Out of Scope

  • agent_session_block/v1 の schema / artifact 実装
  • PostToolUse hook の matcher 仕様変更
  • GitHub Actions artifact workflow の権限や retention 設計変更
  • Secret scan / token revoke / rotate-on-leak の upstream 制御変更
  • exit 2 による AI agent 停止を必要とする enforcement(別 Issue で扱う)

Acceptance Criteria

  • AC1: .claude/settings.json の Stop / SubagentStop は session_manifest_coordinator.sh 単一 hook のみを参照し、guard と producer を sibling hooks として並べない
  • AC2: coordinator は session_recording_policy_guard.sh を producer より先に実行する
  • AC3: guard が exit 0(success)の場合のみ generate_session_manifest_from_hook.mjs を実行する
  • AC4: guard が非0 exit(failure)の場合、標準 agent_session_manifest は生成しない。coordinator は Stop/SubagentStop をブロックせず exit 0 で終了し、stderr に skip 理由だけを出す
  • AC5: producer が失敗した場合も Stop/SubagentStop をブロックせず exit 0 で終了し、stderr に保存失敗だけを出す
  • AC6: stop_hook_active: true の場合、coordinator は producer を呼ばず exit 0 で終了する(short-circuit を維持する)
  • AC7: coordinator は stdin を一度保存し、guard と producer の両方に同一 payload を渡す
  • AC8: Stop/SubagentStop 配下に session_recording_policy_guard.sh や generate_session_manifest_from_hook.mjs への直接参照が残っていないことをテストで確認する
  • AC9: docs/dev/session-recording-policy.md に「session manifest hook は best-effort telemetry であり、AI agent 作業をブロックしない」を明記し、「guard → producer の順に固定」という説明を「single coordinator only」に置換する
  • AC10: 実際の Claude Code agent / subagent 動作で、guard failure・producer failure・artifact write failure の各ケースでも Stop/SubagentStop が完了することを smoke test 証跡として残す

Runtime Verification Applicability

decision: immediate

  • AC1: not_applicable(rg による決定論的ファイル構造検証)
  • AC2: deferred(実装後 PR review 時に pytest で確認)
  • AC3: deferred(実装後 PR review 時に pytest で確認)
  • AC4: deferred(実装後 PR review 時に pytest で確認)
  • AC5: deferred(実装後 PR review 時に pytest で確認)
  • AC6: deferred(実装後 PR review 時に pytest で確認)
  • AC7: deferred(実装後 PR review 時に pytest で確認)
  • AC8: deferred(実装後 PR review 時に pytest で確認)
  • AC9: not_applicable(rg による決定論的テキスト検索)
  • AC10: immediate(実 Claude Code agent / subagent 動作による smoke test、PR 本文に証跡添付。_*_fallback: true を含む結果は PASS と見なさない)

Verification Commands

# AC1
$ rg -n 'session_manifest_coordinator' .claude/settings.json

# AC2
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and guard_order'

# AC3
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and guard_exit_0'

# AC4
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and guard_failure'

# AC5
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and producer_failure'

# AC6
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and stop_hook_active'

# AC7
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and stdin'

# AC8
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and sibling_absent'

# AC9
$ rg -n 'best-effort telemetry|AI agent 作業をブロックしない|single coordinator' docs/dev/session-recording-policy.md

# AC10
# preflight-scope: pr_review_only
$ uv run pytest .claude/hooks/tests/ -q -k 'coordinator and smoke'

$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • .claude/settings.json
  • .claude/hooks/session_manifest_coordinator.sh
  • .claude/hooks/generate_session_manifest_from_hook.mjs
  • .claude/hooks/session_recording_policy_guard.sh
  • .claude/hooks/tests/
  • docs/dev/session-recording-policy.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 動作検証 AC の VC が SKIP(exit 77)を返した場合(実行環境不可のためエスカレーション)
  • fallback 経由でのみ「成功」する場合(FAIL として扱い、実行環境を確認)

Required Skills

  • Bash / shell hook scripting
  • Node.js CLI / JSON stdin contract
  • pytest

ランタイム Smoke 検証手順

以下を実 Claude Code セッションで確認し、証跡を PR に添付する。

  1. normal path: Stop hook が coordinator を起動 → guard pass → producer 実行 → manifest 生成成功 → Claude Code の停止が阻害されない
  2. guard failure path: watched policy file を意図的に不整合にする → guard failure → producer 未実行 → stderr に skip 理由 → Stop/SubagentStop がブロックされない
  3. producer failure path: node 実行失敗または artifacts 書き込み不可を再現 → stderr に保存失敗 → Stop/SubagentStop がブロックされない
  4. subagent path: Task/Subagent を実行し SubagentStop を発火 → failure path でも subagent が終了できる
  5. output safety: stdout に manifest 本文を出さない、stderr に raw transcript / local absolute path / secret-like value を出さない

Scope Delta(任意)

N/A

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jun 4, 2026
  2. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    いぜん日本語制約hookの導入において、大量の厳しいフック制約によるAIエージェント作業の阻止を発生させてしまったので、AIエージェント作業をブロックするようなフックの導入は気をつけて行いたい。特にこのフックは、作業履歴をGitHubに保存するようなもののため、AIエージェントの作業を妨げず、セッション情報の保存失敗だけを出力するような内容にしたいです。
    また、フックの動作を検証して、想定外の動作がないことを実際のAIエージェントの動作から確認したいです。

  3. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES 相当。#651 の方向性は正しいが、Issue契約がまだ甘いです。
    #651 は「blocked Stop/SubagentStop attempt では標準 agent_session_manifest を生成しない」「guard と producer を単一 coordinator hook で直列化する」という実装Issueです。現時点で関連ブランチ/PRはなく、レビュー対象は実装前のIssue契約・設計レビューになります。([GitHub]1)

    関連経緯の整理

    #402 / PR #426 で、Stop/SubagentStop/PostToolUse から agent_session_manifest を生成する配線が入っています。ただし当時は「session_recording_policy_guard.sh を producer より前に書く」構造で、Stop/SubagentStop の manifest 生成を安全に制御できる前提でした。([GitHub]2)

    その後 #433 で、この前提が崩れています。.claude/settings.json に guard と producer を sibling hook として登録すると、Claude Code は同一eventに一致する複数hookを並列実行し、guard が exit 2 しても sibling producer の副作用は止められない、というP0欠陥が明文化されています。つまり「設定順序で guard first」は安全性の根拠になりません。([GitHub]3)

    #651 はその修正として、Stop/SubagentStop を単一 coordinator hook に置き換え、guard exit 2 のとき標準manifestを生成しない、guard exit 0 のときだけ producer を呼ぶ、という狙いです。これは妥当です。([GitHub]1)

    ただし、Claude Code の hook 仕様上、exit 2 は Stop/SubagentStop をブロックする特別な終了コードで、exit 1 は多くの文脈で非ブロッキングです。また PostToolUse は実行後hookなので、exit 2 でも「ツール実行そのもの」は止められません。ここを曖昧にすると、#651 はまた policy illusion になります。([Claude Code]4)

    Blockers

    1. .claude/settings.json の不変条件が弱い

    #651 のACは「Stop/SubagentStop は coordinator のみ」としているものの、実装者が producer 直呼びを残してもテストが甘いとすり抜けます。現在の main では Stop/SubagentStop に session_recording_policy_guard.sh と generate_session_manifest_from_hook.mjs が sibling 登録されており、まさに #433 の欠陥構造です。([GitHub]5)

    要求すべき不変条件:

    • Stop の hook entry は session_manifest_coordinator.sh のみ。
    • SubagentStop の hook entry も session_manifest_coordinator.sh のみ。
    • Stop/SubagentStop 配下に session_recording_policy_guard.sh や generate_session_manifest_from_hook.mjs への直接参照が残っていたらテスト失敗。
    • PostToolUse の producer 直呼びは今回スコープ外として残してよい。

    これは「順序テスト」ではなく「sibling producer 不在テスト」に変えるべきです。

    2. coordinator は stdin を一度捕捉して guard / producer に再注入しないと壊れる

    現行の session_recording_policy_guard.sh は stdin を読み切って一時ファイルに保存します。producer も stdin から hook payload を読む実装です。したがって coordinator が単純に guard | producer や順次実行だけをすると、producer 側に元payloadが渡らず、Stop/SubagentStop の session情報・subagent情報が欠落します。([GitHub]6) ([GitHub]7)

    要求仕様:

    tmpdir="$(mktemp -d)"
    trap 'rm -rf "$tmpdir"' EXIT
    
    stdin_file="$tmpdir/hook-input.json"
    cat > "$stdin_file"
    
    set +e
    "$guard" < "$stdin_file"
    guard_status=$?
    set -e
    
    case "$guard_status" in
      0) ;;
      2) exit 2 ;;
      *) exit 2 ;;
    esac
    
    node "$producer" < "$stdin_file" || true
    exit 0

    重要なのは、guard と producer の両方に同一stdinを渡すことです。

    3. guard の非0終了を fail-closed にしていない

    #651 のACは guard exit 2 の扱いは書いていますが、guard が exit 1 や不明な非0で落ちた場合の扱いが弱いです。Claude Code 仕様では、Stop/SubagentStop を確実に止めるには exit 2 が必要です。(Claude Code)

    推奨: coordinator は guard の 0 以外を原則 fail-closed とし、2 以外の非0も sanitized stderr を出して exit 2 に正規化するべきです。guard のクラッシュ時に producer が走るのは最悪です。

    4. stop_hook_active の扱いが未定義

    Claude Code の Stop/SubagentStop input には stop_hook_active があり、stop hook による無限ループを避けるために確認すべき値です。SubagentStop にも同様の制御情報が入ります。([Claude Code]4)

    現行guardは stop_hook_active == true のとき exit 0 で抜けます。([GitHub]6)
    #651 のACは「既存の short-circuit semantics を壊さない」と言っていますが、その後 producer を呼ぶのか呼ばないのかが未定義です。

    敵対的には、ここは duplicate manifest / stop-loop 副作用の温床です。
    推奨は、coordinator 側で stop_hook_active: true を検出したら producerを呼ばず exit 0。少なくとも、このケースの期待挙動をACとテストに明記すべきです。

    5. docs が現在の危険な説明を残している

    現行docsは Stop/SubagentStop について「policy guard → producer の順に固定」と説明しています。([GitHub]8)
    しかし #433 で、その説明は安全性の根拠として否定されています。([GitHub]3)

    修正文言はこうするべきです。

    Stop/SubagentStop は sibling hooks を使わず、単一 session_manifest_coordinator.sh が stdin を捕捉し、policy guard を先に実行する。guard が exit 2 または非0で失敗した場合、標準 agent_session_manifest producer は呼ばない。

    「設定順序で守る」という表現は削除対象です。

    6. #412 / PR #495 の secret boundary と混同してはいけない

    #651 は blocked Stop/SubagentStop の標準manifest抑止であり、secret boundary そのものではありません。#412 / PR #495 は PreToolUse の secret_boundary_guard.sh、permissions deny/ask、secret-safe workflow を扱う別境界です。([GitHub]9) ([GitHub]10)

    #651 のdocsで「coordinator により秘密情報漏洩を防ぐ」と書くのは過大主張です。正しくは、blocked Stop/SubagentStop attempt に対する標準manifest生成を抑止するだけです。secret流入防止は #412 系の責務です。

    7. GitHub Actions artifact を「private」と誤記してはいけない

    GitHub Actions artifact は public repo では read access があれば取得可能で、REST API 経由で artifact metadata / download endpoint が提供されています。public resource なら認証不要で使えるendpointもあります。([GitHub Docs]11)

    したがって #651 のdocs更新では、PR #426 のレビューで指摘された通り、artifact を confidentiality boundary と扱ってはいけません。artifact retention や digest validation は有用ですが、秘密保持ではありません。([GitHub]12) ([GitHub Docs]13)

    強化すべき受け入れ条件

    #651 のACは次のように補強すべきです。

    1. Stop/SubagentStop の .claude/settings.json entry は coordinator 1本のみ。direct guard / direct producer が残っていたら失敗。
    2. coordinator は stdin を一度保存し、同一payloadを guard と producer に渡す。
    3. guard exit 2 では producer を呼ばず、coordinator も exit 2。
    4. guard の未知の非0終了も fail-closed として exit 2。
    5. guard exit 0 の場合のみ producer を呼ぶ。ただし stop_hook_active: true の期待挙動を明文化する。
    6. SubagentStop payload の agent_id / agent_type / agent_transcript_path を落とさないテストを入れる。
    7. docs から「hook順序で guard first」を削除し、「single coordinator only」に置換する。
    8. 実装: blocked Stop/SubagentStop attempt で標準 manifest を抑止する coordinator hook を導入する #651 では agent_session_block/v1、GitHub Actions retention/security、secret rotation、PostToolUse matcher拡張には触れない。

    実装方針

    .claude/settings.json は Claude Code 公式仕様に合わせ、exec form を維持すべきです。args がある場合は shell tokenization されず、command が直接 executable として spawn されます。Node script の場合も command: "node", args: ["..."] が推奨形です。([Claude Code]4)

    Stop/SubagentStop では例えば次の形が妥当です。

    {
      "matcher": "",
      "hooks": [
        {
          "type": "command",
          "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/session_manifest_coordinator.sh",
          "args": []
        }
      ]
    }

    producer を直接呼ぶ構造は PostToolUse に限定します。PostToolUse は「事後hook」であり、Stop/SubagentStop のような停止制御とは性質が違うためです。([Claude Code]4)

    貼れるレビューコメント案

    REQUEST_CHANGES. #651 の coordinator 化は必要だが、現在のIssue契約だと #433 のP0欠陥を完全には潰せない。Stop/SubagentStop で sibling producer が一切残らないことを settings 構造テストで保証し、coordinator は stdin を一度保存して guard / producer に同一payloadを再注入する必要がある。guard exit 2 だけでなく未知の非0終了も fail-closed に正規化し、producer を呼ばず exit 2 にするべき。stop_hook_active: true 時に producer を呼ぶか呼ばないかも未定義なのでACへ追加してほしい。docs の「guard → producer の順に固定」という説明は #433 の結論と矛盾するため、「single coordinator only」に置換が必要。#651 は secret boundary や artifact confidentiality のIssueではないため、#412/#495 の責務と混同しないこと。

  4. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    #651 (comment)

    結論: この人間コメントは正しいです。#651 は現状のままだと危険です。
    特に #651 の AC2 は「guard が exit 2 の場合、coordinator も exit 2 を返す」としており、Claude Code の Stop/SubagentStop では exit 2 が「停止を阻止して会話・サブエージェントを継続させる」動作になります。これは、人間コメントの「AIエージェント作業をブロックしない」という要求と正面衝突します。([GitHub]1) ([Claude API Docs]2) ([Claude API Docs]2)

    敵対的レビュー

    #651 の設計意図である「guard → producer の直列化」は妥当です。親 Issue #433 でも、Stop/SubagentStop に guard と producer を sibling hooks として並べると、Claude Code では一致した hook が並列実行されるため、guard の exit 2 では兄弟 hook の副作用を止められない、という問題が明記されています。Claude Code 公式 docs も「All matching hooks run in parallel」としているため、coordinator 化そのものは必要です。([GitHub]3) ([Claude API Docs]2)

    ただし、coordinator 化 = blocking policy にすること、ではありません。
    #651 は「blocked attempt では標準 manifest を生成しない」ことと、「AI作業を止める」ことを混同しています。セッション履歴保存・manifest 生成は観測/証跡系の副作用なので、保存失敗で Stop/SubagentStop をブロックする設計は過剰です。現在の generate_session_manifest_from_hook.mjs もコメント上は「producer failure exits 0」「best-effort telemetry — session is NOT blocked」としており、むしろ人間コメントの方向に寄っています。([GitHub]4)

    一番危ないのは、session_recording_policy_guard.sh の exit 2 を coordinator がそのまま返す設計です。Stop/SubagentStop で exit 2 を返すと、Claude は止まらず、サブエージェントも終了できません。過去に日本語制約 hook で作業阻止を起こした反省を踏まえるなら、#651 は 「保存・記録系 hook は fail-open」 を明示する必要があります。([GitHub]5) ([Claude API Docs]2)

    #651 の修正方針

    #651 は次のように契約を変えるべきです。

    1. Stop / SubagentStop の coordinator は 原則 exit 0 固定。
    2. guard が失敗した場合は producer を実行しない。ただし stderr に「manifest skipped / policy guard failed」を出して exit 0。
    3. producer が失敗した場合も 保存失敗を stderr に出すだけで exit 0。
    4. exit 2 を返す挙動が必要なら、それは「session recording policy enforcement」という別 Issue に分離する。
    5. 実装: blocked Stop/SubagentStop attempt で標準 manifest を抑止する coordinator hook を導入する #651 の目的は「標準 manifest の誤生成抑止」と「作業非阻害」の両立に限定する。

    つまり、#651 の中核はこうです。

    guard pass      -> producer 実行 -> 成功/失敗に関係なく exit 0
    guard fail      -> producer skip -> stderr に理由出力 -> exit 0
    invalid stdin   -> producer skip または fallback -> exit 0
    artifact write fail -> stderr に保存失敗出力 -> exit 0
    

    Acceptance Criteria の差し替え案

    そのまま #651 に貼るなら、AC はこう直すのが安全です。

    ## Revised Acceptance Criteria
    
    - AC1: `.claude/settings.json` の Stop / SubagentStop は `session_manifest_coordinator.sh` 単一 hook のみを参照し、guard と producer を sibling hooks として並べない。
    - AC2: coordinator は `session_recording_policy_guard.sh` を producer より先に実行する。
    - AC3: guard が success の場合のみ `generate_session_manifest_from_hook.mjs` を実行する。
    - AC4: guard が failure / would-block 相当の結果を返した場合、標準 `agent_session_manifest` は生成しない。ただし coordinator は Stop/SubagentStop をブロックせず `exit 0` で終了し、stderr に skip 理由だけを出す。
    - AC5: producer が失敗した場合も Stop/SubagentStop をブロックせず `exit 0` で終了し、stderr に保存失敗だけを出す。
    - AC6: `stop_hook_active: true` の既存 short-circuit semantics を壊さない。
    - AC7: `docs/dev/session-recording-policy.md` に「session manifest hook は best-effort telemetry であり、AI agent 作業をブロックしない」ことを明記する。
    - AC8: 実際の Claude Code agent / subagent 動作で、guard failure・producer failure・artifact write failure の各ケースでも Stop/SubagentStop が完了することを smoke test 証跡として残す。

    検証で必須にすべきこと

    unit test だけでは不足です。今回の論点は「hook が本当に AI エージェントを止めないか」なので、実際の Claude Code 動作で確認すべきです。

    ## Runtime Smoke Verification
    
    以下を実 Claude Code セッションで確認する。
    
    1. normal path:
       - Stop hook が coordinator を起動する
       - guard pass
       - producer 実行
       - manifest 生成成功
       - Claude Code の停止が阻害されない
    
    2. guard failure path:
       - watched policy file を意図的に不整合にする
       - guard failure 相当になる
       - producer は実行されない
       - stderr に skip 理由が出る
       - Stop/SubagentStop はブロックされない
    
    3. producer failure path:
       - `node` 実行失敗、producer script path 不正、または artifacts 書き込み不可を再現する
       - stderr に保存失敗が出る
       - Stop/SubagentStop はブロックされない
    
    4. subagent path:
       - Task/Subagent を実行し、SubagentStop hook を発火させる
       - failure path でも subagent が終了できる
    
    5. output safety:
       - stdout に manifest 本文を出さない
       - stderr に raw transcript、local absolute path、secret-like value を出さない

    Issue コメント案

    この Issue は現状のままだと危険です。
    
    過去に日本語制約 hook で AI エージェント作業を阻害した経緯があるため、今回の session manifest / GitHub 保存系 hook は blocking policy として扱わないでください。
    
    特に現行 AC2 の「guard が exit 2 の場合は coordinator も exit 2 を返す」は修正が必要です。Claude Code の Stop/SubagentStop における exit 2 は、停止を阻止して会話または subagent を継続させる挙動です。これは「作業履歴保存に失敗しただけで AI agent 作業を止めない」という運用要求に反します。
    
    この Issue の目的は以下に限定したいです。
    
    - guard と producer を sibling hooks にせず coordinator で直列化する
    - guard failure / blocked attempt では標準 agent_session_manifest を生成しない
    - ただし Stop/SubagentStop はブロックしない
    - producer failure / artifact write failure は stderr に保存失敗を出すだけで exit 0
    - 実 Claude Code agent / subagent 動作で、失敗時にも作業終了が阻害されないことを確認する
    
    修正してほしい AC:
    
    - coordinator は Stop/SubagentStop で原則 exit 0
    - guard failure 時は producer skip + stderr warning + exit 0
    - producer failure 時は stderr warning + exit 0
    - exit 2 による作業阻止が必要な enforcement は別 Issue に分離
    - unit test だけでなく、実際の Claude Code agent / subagent smoke test を必須化
    
    この hook は policy enforcement ではなく best-effort telemetry として扱うべきです。

    判断

    #651 は実装に進める前に契約修正が必要です。
    coordinator 化は正しいですが、exit 2 伝播は削るべきです。履歴保存・manifest 生成の失敗で AI エージェントを止める設計にすると、また hook が開発作業の単一障害点になります。

  5. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Contract Review: BLOCKED (2026-06-06T05:30:00Z)

    VC preflight はすべて pass しましたが、Step 4.5(Runtime Verification Applicability: decision: immediate)で必須項目の欠如を検出しました。

    不足項目

    ## Stop Conditions に 2 エントリの追加が必要

    docs/dev/runtime-verification-policy.md のセクション 6 に従い、以下を ## Stop Conditions の末尾に追加してください:

    - 動作検証 AC の VC が SKIP(exit 77)を返した場合(実行環境不可のためエスカレーション)
    - fallback 経由でのみ「成功」する場合(FAIL として扱い、実行環境を確認)

    ## Runtime Verification Applicability にフォールバック FAIL 明示が必要

    AC10 の immediate エントリに、_*_fallback: true を PASS と見なさない旨を追記してください:

    - AC10: immediate(実 Claude Code agent / subagent 動作による smoke test、PR 本文に証跡添付。fallback 経由の成功は PASS としない)

    その他のチェック結果(すべて pass)

    確認項目 結果
    テンプレート準拠 ✅ pass
    state/needs-human ラベル ✅ なし
    Allowed Paths ✅ 記載あり
    VC 記載 ✅ あり
    Stop Conditions(標準 6 項目) ✅ pass
    ブロッカー ✅ なし
    VC preflight ✅ pass(baseline fail=2, skipped=8, regression_gate pass=4)
    Product Spec ✅ not_applicable / pass
    AC 検証可能性 ✅ pass
    Worktree/Branch 衝突 ✅ なし

    推奨アクション

    上記 2 点は小さな追記です。issue-refinement-loop を使わず、直接 gh issue edit で修正してから issue-contract-review を再実行してください。


    CONTRACT_REVIEW_RESULT_V1:
      status: blocked
      generated_at: "2026-06-06T05:30:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/651
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 2
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 4
          vc_skipped: 8
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: propose_refinement_loop
      blocked_reasons:
        - check: runtime_verification_applicability
          detail: "decision: immediate (AC10) に必要な Stop Conditions エントリ 2 件が欠如"
        - check: runtime_verification_applicability
          detail: "フォールバック経由の成功を PASS としない旨が明示されていない"
      body_sha256: "sha256:252d5e9c936ff4ca1e5ec859941ca91748be078dd9518ee0027adb16d6c0a2fb"
  6. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-06-06T05:35:00Z)

    全チェックが通過しました。implement-issue への handoff 準備ができています。

    • Outcome: Stop / SubagentStop で coordinator hook が guard verdict を直列確定する。guard failure 時は標準 agent_session_manifest を生成せず coordinator は exit 0 で終了し(AI agent 作業を阻止しない)、対応テストと policy 文書が coordinator の best-effort テレメトリとしての位置付けに一致している状態。
    • Acceptance Criteria: AC1〜AC10(AC2〜AC8, AC10 pytest は pr_review_only; AC1, AC9 は baseline fail 確認済み; AC10 smoke test は immediate / 証跡 PR 添付)
    • Allowed Paths:
      • .claude/settings.json
      • .claude/hooks/session_manifest_coordinator.sh
      • .claude/hooks/generate_session_manifest_from_hook.mjs
      • .claude/hooks/session_recording_policy_guard.sh
      • .claude/hooks/tests/
      • docs/dev/session-recording-policy.md
    • Worktree: .claude/worktrees/issue-651-blocked-stop-subagentstop-attempt-manife
    • Branch: worktree-issue-651-blocked-stop-subagentstop-attempt-manife
    • VC preflight: baseline fail = 2, 想定外 pass = 0, 実行不可 = 0, skipped (pr_review_only) = 8, regression_gate pass = 4
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-06T05:35:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/651
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 2
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 4
          vc_skipped: 8
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
        runtime_verification_applicability:
          decision: immediate
          status: pass
          applicable_acs: [AC10]
          execution_env: "実 Claude Code セッション(ローカル hook テスト)"
          skip_stop_condition: present
          fallback_fail_explicit: present
          artifact_requirement: "PR 本文に証跡添付"
      next_action: implement_issue
      blocked_reasons: []
      body_sha256: "sha256:c08edffbb4c54da90fa3558f8bd7ef7d6c0a1c10375a11b5fd821a05afb4bbcc"
  7. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

    • PR: feat(#651): blocked Stop/SubagentStop attempt で標準 manifest を抑止する coordinator hook を導入する #694
    • Worktree: .claude/worktrees/issue-651-blocked-stop-subagentstop-attempt-manife
    • Branch: worktree-issue-651-blocked-stop-subagentstop-attempt-manife
    • 検証: 4/4 PASS (typecheck / lint / pnpm test 371件 / build)
    • pytest coordinator テスト: 16 PASS
    • AC1 (rg): PASS
    • AC9 (rg): PASS
    • AC10 (smoke): guard failure / producer failure / stop_hook_active short-circuit / SubagentStop 全パスで exit 0 確認
    • 事前失敗: test_secret_boundary_contract.py boundary_enforced (Allowed Paths 外・スコープ外)
    • 後続: PR レビュー (pr-review-judge) → マージ → post-merge-cleanup
  8. added 2 commits that reference this issue on Jun 6, 2026
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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions