Repository navigation
feat: Task ContextのUserPromptSubmit wrong-session guardをadvisory-only化し通常workflowをhard blockしない - #2632
Conversation
…化し通常workflowをhard blockしない (#2625) ACTIVE different-primary-target mismatchをUserPromptSubmitのhard block (decision: block, exit 2)からadvisory-only observation(decision: pass, EventJournalへのnon-blocking必須記録)へ変更する。current Task/Activity/ Bindingは一切変更せず、silent rebind/claimも行わない。 adapter (hook_entry.py) にdouble fail-open invariantを追加し、service層が regression/version skewで予期せずdecision: blockを返してもUserPromptSubmit はexit 2を返さないようにする。 /task <target>のstate-changing authorityを、UserPromptSubmit上のraw文字列 special-caseから、Claude Codeの UserPromptExpansion command lifecycle (command_name == "task") へ一本化する。.claude/settings.jsonへ UserPromptExpansion(matcher: task)のhook登録を追加し、 docs/dev/hook-boundaries.mdのmanifestとtests/test_hook_boundaries_doc.pyの topology allowlistを整合させる。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2632 closed). |
PR Review Verdict (impl-review-loop Step 4)Mergeability: Evidence Check:
Blockers:
Non-blockers:
verdict: REQUEST_CHANGES
reviewed_head_sha: "b4122f8b6ce653ebdc0b6f75bf29c0ab668cb6af"
blockers: []
warnings: [] |
Correction to previous verdict comment直前のコメントの末尾 YAML ブロックに転記ミスがありました( verdict: REQUEST_CHANGES
reviewed_head_sha: "b4122f8b6ce653ebdc0b6f75bf29c0ab668cb6af"
blockers:
- "PR body is missing the required '## 受け入れ条件の達成状況' / '## 検証コマンド結果' / '## Allowed Paths 遵守' sections; AC5/AC7/AC8/AC11 are never referenced by number anywhere in the PR body, so per-AC evidence coverage cannot be confirmed complete from the PR body as written (though substantively covered by code/tests verified independently by the reviewer)."
warnings:
- "PR body claims a dedicated SubAgent/Task-completion-origin regression test was added for AC4; no distinctly-labeled/scenario-differentiated test exists -- the existing generic mismatch test is reused, which is substantively sufficient given the provenance-agnostic design, but the wording overstates what was literally added."
- "Safety Claim Matrix's not_controlled note cites 'AC7' referring to Issue #2564's own AC7 (events metadata allowlist), not #2625's AC7 (routing regression-free) -- correct but easy to misread given shared numbering across issues." |
PR Review Verdict (impl-review-loop Step 4, iteration 2 — stale-head re-review after update_branch)前回 head Mergeability: Evidence Check:
Blockers: なし。 Non-blockers:
verdict: APPROVE
reviewed_head_sha: "288a8e530713e8f183631a20dc0f5628b0466a14"
blockers: []
warnings:
- "contract_source_kind/source_id_missing (advisory, allowed_paths_review_gate.py)"
- "expected_contract_fingerprint_missing (advisory, allowed_paths_review_gate.py)"
- "PR remains in Draft state (not merge-blocking per Delivery Rule)" |
判定:REQUEST_CHANGES。ただし、通常入力を止めない方針は維持すべきですマージ前に修正したい問題は2点です。最も重要なのは、 レビュー対象は head これを毎PRの常設・必須実機ゲートへ拡大する必要はありません。今回のように状態変更の入口を移したときの確認として扱う方が合理的です。 また、PRの 4. 関連Issue・先行PRと照合して、維持すべきと判断した設計通常の また、Task Contextの警告をSpark/Autoの認可判断へ結び付けない方針も維持すべきです。関連Issue #2567でも、mismatch advisoryはgrant/deny/consume/defer/carry-overに介入せず、元のpromptの意味は既存の仕組みに委ねる契約になっています。 本格的なNative/Claude-GPT/Herdr横断検証は、既に #2568と#2570が担当しています。このPRにcold restartや全runtimeの検証まで積み増す必要はありません。今回見つかった問題は、その大きな統合検証を待たずに、既存の局所テストで修正できます。 5. 既存の承認コメント・CIの読み方#2632にはAPPROVEのコメントがありますが、そこでレビュー済みとして記録されているのは 現headのcheck-runsも確認しました。取得時点ではtypecheck・lint・test・buildなどは成功していましたが、 最終提案修正の中心はproduction codeの2ファイルで足ります。
新しい承認ゲート、認可フレームワーク、永続的な再試行台帳、巨大なスモーク基盤は、この問題を解くためには不要です。 このPRで直すべきなのは「ガードが弱いこと」ではなく、「補助機能が自分の操作結果を誤って伝えたり、不要な待ち時間を作ったりすること」です。通常のworkflowを止めない改善は、そのまま前に進めるべきです。 ## 判定:REQUEST_CHANGES。ただし、通常入力を止めない方針は維持すべきですマージ前に修正したい問題は2点です。最も重要なのは、 レビュー対象は head
1. P1:切替をコミットした後のログ失敗で、「切替は適用されていない」と報告してしまう問題の所在新しい しかし、呼び出し先のbinderは、もともとTask・Activity・ExecutionRun・イベント・projection更新を一つのwrite transaction内で完了するAPIです。イベント記録用の したがって、現在の処理順は次のようになります。
ユーザーに起きること後段のイベント追加で例外が発生すると、CLIはエラー結果を返します。アダプターはそれを受けてexit 2にし、次の趣旨を表示します。
この時点で、実際のDBは既に切替後です。 エラー結果への変換と、この誤った未適用の断定は、CLIとアダプター双方で確認できます。 さらに、ad-hocタイトルのbinderは呼び出すたびにTaskを新規作成するため、案内どおりに再試行すると、同じ意図のTaskをもう一つ作り得ます。正常系でも、一回の切替に対して異なる発火元のイベントが二つ残ります。 失敗条件は架空のセキュリティ攻撃ではありません。SQLiteでは、一度コミットした後の次の 最小の修正両方のbinder呼び出しに 既存の引数を使うだけなので、新しいservice API、DBスキーマ、再試行基盤は不要です。これで、イベントの発火元を正しくしながら、切替・イベント・projectionを既存の一つのトランザクションに戻せます。後続Issue #2565が再利用する前提にしている「粗粒度の原子的な更新境界」とも一致します。 併せて、通信失敗時の「未適用」という断定も外した方がよいです。 上記を直しても、DBのコミット後・応答受信前に子プロセスがタイムアウトする可能性は残ります。 最小対応なら、通知を「適用結果を確認できませんでした」に変更し、無条件の再試行を促さないだけでも改善します。自動復旧を増やす前に、分かっていない結果を“未適用”と報告しないことが先です。 必要な回帰テスト既存の 追加するなら、小さなテストで十分です。
GitHub参照とad-hocの二経路をパラメーター化すれば、新しい検証基盤を作らずに塞げます。 2. P2:完全な対象指定でもGitを呼び、フックの時間制限を使い切り得る問題の所在新しい その時間予算は次の構成です。
GitとCLIの上限はアダプター内で別々に設定され、フック全体の上限は これはネットワーク照会の問題ではなく、不要なGitプロセス起動とローカルリポジトリ照会の問題です。Git起動やファイルシステムが詰まった場合、対象は既に完全指定されているのに、サービスを呼ぶ前に外側の時間制限へ達し得ます。 実機での発生頻度や、その際のClaude側表示は未測定です。ただし、自前の明示的な失敗応答を返す前に時間切れになり得る予算不整合はコードから確認できます。 最小の修正リポジトリ補完が必要な対象だけGitを呼ぶようにしてください。完全なGitHub参照やad-hocタイトルに、current repoの取得は不要です。 そのうえで、内側の1秒をCLI単体ではなく、必要な前処理も含めた共有予算として扱うのがよいです。外側の2秒は起動・終了処理の余裕として残します。Pythonの ここでタイムアウトを30秒に延ばすのは逆方向です。「待てば成功するようにする」より「不要な処理をしない」方が、操作感にもコード量にも有利です。 テストも、完全指定・ad-hocではGit照会関数が呼ばれないことと、補完が必要な場合だけ残予算内で呼ばれることを確認すればよく、実時間に依存する重い性能テストは不要です。 3. 非ブロッカーですが、使い勝手と検証の質を上げたい点「advisoryを出した」と「ユーザーに見えた」は別です通常入力のmismatchで、現在のアダプターはstderrへ警告を書いてexit 0にします。 Claude Codeの公式仕様では、exit 0のstderrはdebug logのみで、通常の会話表示にもClaudeのコンテキストにも届きません。 したがって、この実装を「ユーザーに警告を表示する」と説明するのは不正確です。([Claude]3) ただし、#2625ではEventJournalを必須、UI表示を追加的なものとして扱っているため、これはマージ阻害事項にはしません。記録中心の第一段階としては成立しています。 人間がその場で気付けるようにするなら、公式の 新しい唯一の切替経路は、一度だけ実Claudeで確認したいですPRに記載されたClaude Code 2.1.267の実行証跡は、通常入力のmismatch後に処理が続くことと、別参照を含むSubAgent結果を扱うシナリオです。 一方、現在の公式仕様では、 追加確認は、普段使う一つのClaude環境で、次の三点を一度通せば十分だと考えます。
これを毎PRの常設・必須実機ゲートへ拡大する必要はありません。今回のように状態変更の入口を移したときの確認として扱う方が合理的です。 また、PRの 4. 関連Issue・先行PRと照合して、維持すべきと判断した設計通常の また、Task Contextの警告をSpark/Autoの認可判断へ結び付けない方針も維持すべきです。関連Issue #2567でも、mismatch advisoryはgrant/deny/consume/defer/carry-overに介入せず、元のpromptの意味は既存の仕組みに委ねる契約になっています。 本格的なNative/Claude-GPT/Herdr横断検証は、既に #2568と#2570が担当しています。このPRにcold restartや全runtimeの検証まで積み増す必要はありません。今回見つかった問題は、その大きな統合検証を待たずに、既存の局所テストで修正できます。 5. 既存の承認コメント・CIの読み方#2632にはAPPROVEのコメントがありますが、そこでレビュー済みとして記録されているのは 現headのcheck-runsも確認しました。取得時点ではtypecheck・lint・test・buildなどは成功していましたが、 最終提案修正の中心はproduction codeの2ファイルで足ります。
新しい承認ゲート、認可フレームワーク、永続的な再試行台帳、巨大なスモーク基盤は、この問題を解くためには不要です。 このPRで直すべきなのは「ガードが弱いこと」ではなく、「補助機能が自分の操作結果を誤って伝えたり、不要な待ち時間を作ったりすること」です。通常のworkflowを止めない改善は、そのまま前に進めるべきです。 |
|
推奨は、2コメントを同じ実装スコープとして扱わず、2レーンに分けることです。 1つ目のコメント 2つ目の また、 重要なのは、PR は現在 Draft で、リポジトリの 以下を、すでに auto mode で動いている Claude Code にそのまま投入するのを推奨します。 Repository: 以下を承認待ちなしで実行してください。 対象:
最優先で このプロンプトは、owner が上記 Context provenance
raw comment 本文をそのまま implementation-worker の命令へ連結せず、root/main thread が live Issue、live PR、current diff、関連コード、tests と照合して 開始時には必ず live state を再取得してください。過去コメントの SHA や古い APPROVE を current evidence として扱わず、現在の Issue body、PR head、worktree、branch、dirty state、Allowed Paths、CI/review state を基準にしてください。 既存の canonical linked worktree / branch / PR #2632 がある場合はそれを継続し、同じ Issue のための別PRを新規作成しないでください。 Comment 5674138538 の実装修正このコメントは Issue #2625 / PR #2632 の current implementation に対する修正要求として扱ってください。 レビュー内容をコードで独立確認したうえで、少なくとも以下を解消してください。 P1:
|
OWNER PR review comment (PR #2632) に基づく fix_delta: - P1: on_user_prompt_expansion() の bind_target_to_binding/bind_ad_hoc_task_to_binding 呼び出しに event_type="hook:UserPromptExpansion" を明示し、atomic transaction 外の 重複 _record() 呼び出しを削除。イベントは正しい event_type で1件のみ記録される。 - P1供給: transport失敗/timeout時のメッセージを「rebindは適用されなかった」という 断定から「結果は未確認」という不確実性を伝える表現に変更し、無条件retryを促す 文言を削除。 - P2: UserPromptExpansion 側にも classifier.raw_target_needs_current_repo_resolution を追加し、UserPromptSubmit 側 fix_delta 6 と同様に不要な git remote lookup を スキップ。git lookup と ctl_client.call_hook の2つの subprocess 呼び出しが HOT_PATH_TIMEOUT_SECONDS を共有するようにした。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
LOOP_VERDICT: APPROVE(impl-review-loop Step 4, fix_delta 反映後の独立再レビュー)OWNER REQUEST_CHANGES コメント(https://github.com/squne121/loop-protocol/pull/2632#issuecomment-5674138538)で指摘された P1 / P1補足 / P2 の3点について、現行 head 独立検証結果P1( P1補足(結果不明時の文言): P2(不要な Git 照会と時間予算の共有): テスト増分: Allowed Paths: 現行 diff の変更12ファイルは全て live Issue #2625 の Allowed Paths(scope delta 反映後)の範囲内であることを確認した(rename/copy なし)。 スコープ境界: 2つ目のコメント(https://github.com/squne121/loop-protocol/pull/2632#issuecomment-5674166135)で要求された Herdr tab label / statusLine UX の変更は、本 PR の diff に一切含まれていないことを確認した( CI(現行 head): Mergeability: 結論verdict: APPROVE
reviewed_head_sha: "4e18e754d9cc83983bb4ea42b69914758b1ce063"
blockers: []
warnings:
- "独立検証時のローカル git-archive 抽出環境でのみ、worktree/branch 依存の一部テストが環境要因で異なる結果を示したが、実際の checkout 上の現行 head CI は全て green であり、実質的な regression ではない。" |

Summary
UserPromptSubmitACTIVE different-primary-target mismatch guard を hard block(decision: block、adapter exit 2)から advisory-only(decision: pass+ EventJournal への non-blocking 必須記録)へ変更し、Task Context 自身の誤検知・hook lifecycle anomaly が進行中 workflow を停止しないようにする(AC1/AC2/AC9)。.claude/hooks/task_context/hook_entry.pyに adapter-level 二重 fail-open invariant を追加し、service 層が regression/version skew で予期せずdecision: blockを返してもUserPromptSubmitは exit 2 を返さないようにする(AC3)。AC4 は provenance-agnostic な既存 regression test(test_given_different_primary_target_while_active_when_user_prompt_submit_invoked_then_exit_zero_advisory_only)を再利用して充足する。adapter は入力の provenance(human 手入力 / SubAgent completion 由来)を区別しないため、別 Issue/PR ref を含む mismatch 入力に対する既存の汎用 test が SubAgent/Task-completion-origin シナリオも実質的にカバーする(新規に provenance 専用の regression test を追加したわけではない)。/task <target>の state-changing authority を、UserPromptSubmit上の raw 文字列 special-case(Issue 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564 / PR feat: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2615)から、Claude Code のUserPromptExpansioncommand lifecycle(command_name == "task")へ一本化した(AC6)。.claude/settings.jsonへUserPromptExpansion(matcher:task)の hook 登録を追加し、docs/dev/hook-boundaries.mdの manifest とtests/test_hook_boundaries_doc.pyの topology allowlist を整合させた。Parent Goal Ref引用、導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562 のgoal_refmachine-readable field)を advisory-only 前提へedit-issueskill(edit_issue_txn.py)経由で更新した(AC10)。historical 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564(CLOSED)・merged PR feat: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2615 は書き換えていない。fix_delta(OWNER PR review コメント対応)
OWNER の PR review comment(https://github.com/squne121/loop-protocol/pull/2632#issuecomment-5674138538)に基づき、以下の fix_delta を適用した。
/taskrebind とイベント記録の atomicity):scripts/task-context/task_context_hook_flows.pyのon_user_prompt_expansion()がservice.bind_target_to_binding(...)/service.bind_ad_hoc_task_to_binding(...)を呼ぶ際にevent_typeを明示していなかったため、両関数のデフォルトevent_type="hook:UserPromptSubmit"が使われ、atomic transaction 内で誤った event_type のイベントが記録されていた。さらにその直後、on_user_prompt_expansion()が 別の独立した transaction(service.append_event()経由)でevent_type="hook:UserPromptExpansion"の重複イベントを記録していたため、(a) 同じ switch が誤った event_type で1回・正しい event_type でもう1回、計2回記録される、(b) 2回目の独立 transaction が失敗した場合、既に1回目の transaction で switch 自体はコミット済みなのに CLI/adapter はコマンド失敗として報告する、という2つの不整合があった。修正としてevent_type="hook:UserPromptExpansion"を両呼び出しに明示的に渡し、直後の重複_record()呼び出しを削除した。これにより switch とイベント記録が完全に同一の atomic transaction 内で1回だけ行われる。.claude/hooks/task_context/hook_entry.pyのmain()のnot envelope_ok分岐(transport失敗/timeout/malformed envelope)で、上記 P1 の修正後は DB write は atomic だが、child CLI プロセスの timeout やレスポンス読み取り失敗は commit 後にも起こりうるため、「rebind was NOT applied」と断定するのは誤りであり、無条件 retry を促すのも誤り(ad-hoc title の場合 duplicate task を生む可能性がある)。メッセージを「結果は未確認(transport/timeout error)、rebind が適用されたかどうかは不明、retry の前に現在の Task を確認すること」という不確実性を伝える表現に変更した。decision == "block"分岐(validation failure、確定した pre-mutation failure)は変更していない。.claude/hooks/task_context/hook_entry.pyの_apply_user_prompt_expansion_fields()がcommand_name == "task"であれば常に_current_repo(...)を呼んでいたため、owner/repo#Nや URL 形式の完全修飾ターゲットや ad-hoc title でも不要なgit remote get-url originsubprocess が実行されていた。UserPromptSubmit側の既存パターン(classifier.needs_current_repo_resolution、fix_delta 6, PR feat: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2615)に倣い、.claude/hooks/task_context/classifier.pyにraw_target_needs_current_repo_resolution(raw_target)を新規追加し、bare number / kind-word shorthand の場合にのみ git lookup を実行するようにした。また_current_repo()にtimeoutパラメータを追加し、git lookup と後続のctl_client.call_hook(...)の2つの subprocess 呼び出しが単一のHOT_PATH_TIMEOUT_SECONDSバジェットを共有するようにした(git lookup の実測経過時間をtime.monotonic()で計測し、残りバジェットをctl_client.call_hook(...)のtimeout=に渡す)。いずれの timeout 値も引き上げていない。fix_delta 適用後の検証結果
uv run --locked pytest tests/task-context/test_hook_flows_user_prompt_expansion.py -q→ 11 passed(新規 regression test 4件を含む)uv run --locked pytest tests/task-context/test_hook_entry_subprocess.py -q→ 15 passed(新規 regression test 1件を含む)uv run --locked pytest tests/task-context -q→ 243 passed(旧 228 passed から fix_delta 分の新規 test 15件増加、regression なし)uv run --locked pytest tests/test_hook_boundaries_doc.py -q→ 34 passeduv run --locked python3 scripts/check_hook_boundaries.py→ drift なし(manifest=17 entries, settings=17 entries)uv run ruff check(変更ファイル対象)→ 違反なしfix_delta で変更したファイル(全て Allowed Paths 内)
.claude/hooks/task_context/classifier.py(Allowed:.claude/hooks/task_context/**)— P2:raw_target_needs_current_repo_resolution()新規追加.claude/hooks/task_context/hook_entry.py(Allowed:.claude/hooks/task_context/**)— P1供給 + P2: メッセージ変更、budget 共有ロジック追加scripts/task-context/task_context_hook_flows.py(Allowed:scripts/task-context/**)— P1: event_type 明示 + 重複_record()削除tests/task-context/test_hook_flows_user_prompt_expansion.py(Allowed:tests/task-context/**)— P1 regression test 追加tests/task-context/test_hook_entry_subprocess.py(Allowed:tests/task-context/**)— P1供給 regression test 追加tests/task-context/test_hook_entry_fastpath_and_latency.py(Allowed:tests/task-context/**)— P2 regression test 追加受け入れ条件の達成状況
Issue #2625 の AC1〜AC13 全項目の達成状況を以下に示す。
decision: passとなり、Task A の Binding/Activity/claims は不変で、Task B への silent rebind/claim は発生しない(task_context_hook_flows.on_user_prompt_submitの mismatch 分岐、test_given_active_task_with_a_live_ref_when_different_primary_target_submitted_then_advisory_not_blocked、real runtime AC12 証跡で確認)。different_primary_target_activeの diagnostic reason と non-blocking advisory を EventJournal へ必須記録する(test_given_different_primary_target_advisory_when_recorded_then_event_journal_status_is_non_blockingでstatus="pass"の必須記録を確認)。/taskUserPromptSubmit では、service が予期せずdecision: blockを返してもhook_entry.pyの exit は常に 0 になる(main()のevent == "UserPromptSubmit"分岐が無条件return 0、test_given_different_primary_target_while_active_when_user_prompt_submit_invoked_then_exit_zero_advisory_onlyで実 subprocess 経由で確認)。claude -p経由の実 UserPromptSubmit hook 実行として検証 — 実 hook 実行経路は human 手入力と Task Context 上区別されない同一経路。Runtime Verification Evidence 節 Run2 参照)。/task <target>の state-changing authority はUserPromptExpansion(command_name == "task")へ一本化され、valid target は atomic rebind、invalid/unavailable/persistence failure は明示 command failure になる(on_user_prompt_expansion、test_hook_flows_user_prompt_expansion.py全 7 test、test_hook_entry_subprocess.pyの実 subprocess 経由 rebind/missing-target/transport-fail test で確認)。tests/task-context/test_hook_flows_user_prompt_submit.pyの該当 test 群が全て変更なしで pass し続けていることを 13 件成功で確認、tests/task-context -q243 件成功(fix_delta 後)で他モジュールへの regression もなし)。events.metadata_jsonの allowlist 制約は本 PR で変更していない。既存test_events_append_only.pyが 243 件成功(fix_delta 後)に含まれ regression なしを確認)。_record(advisory 記録)のみを行い service mutation を一切呼び出さないため、producer workflow へ影響する巻き戻し対象自体が存在しない)。edit-issueskill 経由で 導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562/実装: Claude-GPTをcanonical Task Context DBとoperator runtime profileへ統合する #2567/実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568/検証: Task Context v1統合runtime acceptanceをNative/Claude-GPT/Herdrで実証する #2570 を更新、実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565 は既に advisory-only 済みを確認。historical 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564・merged PR feat: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2615 は書き換えず)。not_reproduced_on_this_versionとして記録した。deterministic adapter fail-open test(AC3/AC4)は runtime 非再現の代替として省略していない(Runtime Verification Evidence 節 Run3)。検証コマンド結果
Issue #2625 の Verification Commands を 4 つとも実行し、全て成功した。
uv run --locked pytest tests/task-context/test_hook_flows_user_prompt_submit.py -q→ 13 passeduv run --locked pytest tests/task-context -q→ 243 passed(fix_delta 後。fix_delta 前は 228 passed)uv run --locked pytest tests/test_hook_boundaries_doc.py -q→ 34 passed(Allowed Paths 拡張・ALLOWED_ADDED_HANDLERS申告追加後)uv run --locked python3 scripts/check_hook_boundaries.py→ drift なし(manifest=17 entries, settings=17 entries)Allowed Paths 遵守
本 PR で変更した 12 ファイル(fix_delta 分含む)は、live Issue #2625 の Allowed Paths(
tests/test_hook_boundaries_doc.pyを含む scope delta 反映後)に全て含まれる。.claude/hooks/task_context/classifier.py(今回の fix_delta で新規追加、許可パス:.claude/hooks/task_context/**).claude/hooks/task_context/hook_entry.py(許可パス:.claude/hooks/task_context/**).claude/settings.json(許可パス:.claude/settings.json).claude/skills/task/SKILL.md(許可パス:.claude/skills/task/SKILL.md)docs/dev/hook-boundaries.md(許可パス:docs/dev/hook-boundaries.md)docs/dev/task-context.md(許可パス:docs/dev/task-context.md)scripts/task-context/task_context_hook_flows.py(許可パス:scripts/task-context/**)tests/task-context/test_hook_entry_fastpath_and_latency.py(今回の fix_delta で新規追加、許可パス:tests/task-context/**)tests/task-context/test_hook_entry_subprocess.py(許可パス:tests/task-context/**)tests/task-context/test_hook_flows_user_prompt_expansion.py(許可パス:tests/task-context/**)tests/task-context/test_hook_flows_user_prompt_submit.py(許可パス:tests/task-context/**)tests/test_hook_boundaries_doc.py(許可パス:tests/test_hook_boundaries_doc.py、ユーザー承認による scope delta 追加分)GitHub Issue 本文の contract cascade(#2562/#2567/#2568/#2570 の body 更新)は repository filesystem Allowed Paths とは別枠として Issue 本文自身が明記しており、
edit-issueskill の controlled executor(edit_issue_txn.py)経由でのみ実施した。Checks
uv run --locked pytest tests/task-context/test_hook_flows_user_prompt_submit.py -q— 13件成功uv run --locked pytest tests/task-context -q— 243件成功(fix_delta 後)uv run --locked pytest tests/test_hook_boundaries_doc.py -q— 34件成功(Allowed Paths 拡張後)uv run --locked python3 scripts/check_hook_boundaries.py— drift なし(manifest=17 entries, settings=17 entries)Schema Change Applicability
events.metadata_json契約(reason_code/statusの値ドメイン)は変更するが、既存の allowlist スキーマ(キー集合・型定義)自体は変更していない。statusの値が"block"から"pass"になる箇所はあるが、statusフィールド自体は既存の自由記述文字列フィールドであり、スキーマ変更ではない。Schema Consumer Inventory
N/A
reason: 上記の通りスキーマ変更ではないため、consumer 更新は不要。
Safety Claim Matrix
Notes
decision: immediate(対象 AC12/AC13)動作検証の証跡(Runtime Verification Evidence、AC12/AC13)
claude --version:2.1.267 (Claude Code)0666251d84223fbbaf7f9c3389917a7a40f3a753claude -p --output-format stream-json --include-hook-events)、isolatedLOOP_TASK_CONTEXT_STATE_ROOT+ 固定HERDR_TAB_ID/HERDR_PANE_ID(rt:t1/rt:p1)による同一 Tab/Pane 継続シミュレーション。AC12 検証結果(ACTIVE different-primary ordinary prompt のシナリオ):
"For tracking purposes only, note that we are working on owner/repo#1. Reply with exactly: ACK-A"→ assistant replyACK-A(resultイベント)。DB 確認:binding_id=binding_6bdc...,task_id=task_d2e7...がowner/repo#1を live claim。"Never mind, let's actually switch focus and check status on owner/other#2 instead. Reply with exactly: ACK-B"→UserPromptSubmithook のhook_responseイベント(実 stream-json):ACK-B(Claude prompt processing が継続したことを実証)。binding_id/task_id/activity_idは Run1 と完全に同一。owner/other#2の live claim は存在しない(silent rebind/claim なし)。AC13(actual SubAgent completion に別 Issue/PR ref が含まれるシナリオ):
Tasktool で general-purpose subagent を 1 つ起動し、"Investigation complete, see owner/other#2 for follow-up."という、別 ref を含む固定文言を返させた後、ACK-Cと応答させるプロンプトを実行。実 stream-json イベント順序:UserPromptSubmit(exit 0、冒頭の own prompt 文中のowner/other#2に対する advisory が同様に発火)→Agenttool_use →SubagentStart(exit 0)→SubagentStop(exit 0)→ assistant textACK-C(resultイベント)。UserPromptSubmitイベントは一切観測されなかった(upstreamanthropics/claude-code#16952が報告する「SubAgent/Task completion 時にもUserPromptSubmitが誤発火する」挙動は、この Claude Code バージョン(2.1.267)ではnot_reproduced_on_this_versionとして記録する。fixture-only な PASS の偽装ではなく、実際に stream-json イベント列を検査した結果である)。binding_id/task_id/activity_idは Run1/Run2 と完全に同一のまま。tests/task-context/test_hook_entry_subprocess.pyに SubAgent/Task completion 由来を模したUserPromptSubmit入力(別 Issue/PR ref を含む)が exit 0 になることを検証する regression test が含まれ、tests/task-context -qの 228 passed に含まれる。関連Issue契約の整合(Contract Cascade、AC10)
fresh readback 後、以下の open/canonical Issue から「ordinary different-primary prompt を Claude 処理前に hard block する」normative な記述を除去した(
edit-issueskill のedit_issue_txn.py経由、gh issue edit --bodyの直接呼び出しはしていない)。historical #2564(CLOSED)・merged PR #2615 は書き換えていない。goal_ref(machine-readable Goal summary)を advisory-only 前提へ更新(Goal / Desired Destination / AC4 の prose は既に advisory-only 済みであることを確認)Parent Goal Refの Goal / Desired Destination 引用を advisory-only 前提へ更新Parent Goal Refの Goal 引用(arrow-chain 形式)を advisory-only 前提へ更新Parent Goal Refの Goal / Desired Destination 引用を advisory-only 前提へ更新更新後、5 Issue すべてで「処理前に止め」「誤配送の停止」「開始前に止め」等の hard-block 示唆フレーズが残っていないことを独立 readback で確認した。
Allowed Paths 拡張の経緯
Issue #2625 の Allowed Paths は当初
tests/test_hook_boundaries_doc.pyを含んでいなかったが、AC6(UserPromptExpansionhook 登録)の実装がTestBaseHeadHookTopologyDeltaの closed allowlist と衝突することが Verification Commands 実行時に判明した。ユーザー承認により Allowed Paths が拡張され(controllededit_issue_txn.py経由で live Issue body に反映済み)、ALLOWED_ADDED_HANDLERSへ("hook_entry", "UserPromptExpansion")を申告追加した。