Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2562"
goal_ref: "Task Contextによるwrong-primary検知を維持しつつ、通常UserPromptSubmitをClaude処理のadmission gateにせず、誤検知・内部通知・hook lifecycle anomalyで進行中workflowを停止しない"
change_kind: workflow
dedupe_key: "task-context-v1:user-prompt-mismatch-advisory-only"Parent Issue
Parent Goal Ref
- Goal: 通常の人間操作を増やさず、HerdrでTabを作成→通常のclaude/Claude-GPT起動→通常のIssue/PR promptでのTask autobind→
/clear後も同一Task維持→/quit後の同一Tab起動でのTask復元→terminal Activityからの合法transition/rebind→ACTIVEな別primary target誤配送の停止→意図的なACTIVE切替は/task <target>のみ→Herdr cold restart後の自動復元、を成立させる(導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562 Goal、2026-09-10時点の記述をそのまま参照) - Desired Destination: Herdr上で最大8程度のNative Claude / Claude-GPT operatorを並列利用しても、Tab位置・worktree・branchをTask identityにせずcurrent Taskを安定識別し、wrong-primary promptをClaude処理前に止め、
/clear・/quit・Herdr cold restartを跨いで必要なTask Contextを復元し、人間は既存Herdr/statusLine上のTask・Activity・Attention・runtime healthを見れば運用できる状態にする(導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562 Desired Destination、parent scope。本Issueのcontract cascadeにより、この一文中の「Claude処理前に止め」は advisory-only 前提へ更新対象となる — 詳細は本Issueの「Owner Decision / Contract Correction」と「Contract cascade」参照)
Source / Related
- 導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562 — Task Context parent
- 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564 — Native Claude operator hooks / wrong-session guard(CLOSED、historical。PR #2615で実装済みのhard-block契約を本Issueがsupersedeする)
- PR feat: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2615 — 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564 implementation
- 実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565 — workflow trusted signals / Issue-PR equivalence
- 実装: Claude-GPTをcanonical Task Context DBとoperator runtime profileへ統合する #2567 — Claude-GPT integration
- 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568 — runtime-smoke Task Context verification
- 検証: Task Context v1統合runtime acceptanceをNative/Claude-GPT/Herdrで実証する #2570 — integrated runtime acceptance
docs/dev/hook-boundaries.md— canonical hook責務/fail-policy/exit-code契約の正本(scripts/check_hook_boundaries.pyが.claude/settings.jsonとdrift検出).claude/skills/task/SKILL.md—/taskescape hatchの現行仕様- upstream: [BUG] UserPromptSubmit hook fires when Task/subagent completes instead of only on user prompt submission anthropics/claude-code#16952 — Task/SubAgent completion時にも
UserPromptSubmitが発火する既知報告(CLOSED状態、close理由の詳細はupstream側の記録に留め、本Issueのcorrectness前提にはしない) - upstream: UserPromptSubmit hook decision:block reason not displayed in VS Code/Cursor extension (recurring; multiple closed dupes) — please re-triage anthropics/claude-code#75534 —
UserPromptSubmitのdecision:block理由がIDE extensionへ表示されない別系統のOPEN issue(参考情報)
Runtime Incident
実Herdr / Native Claude sessionで、Issue #2565 の issue-refinement-loop がfresh semantic reviewer completionを待っていた最中、人間が追加promptを送信していないにもかかわらず次のTask Context blockが発生した。
UserPromptSubmit operation blocked by hook:
[python3 ${CLAUDE_PROJECT_DIR}/.claude/hooks/task_context/hook_entry.py UserPromptSubmit]:
[task-context] blocked: this prompt targets a different ACTIVE Task/Activity
(different_primary_target_active). Use `/task <target>` to explicitly switch Tasks.
直後にSubAgent completion resultがdeliveryされており、今回の入力は意図的なhuman Task switchではなかった。Task Contextがupstream hook lifecycle anomalyをhuman intentとして扱い、進行中workflowを停止した実runtime regressionである。
Owner Decision / Contract Correction
これまでの契約:
ACTIVE current Activity + different primary target
→ UserPromptSubmitでBLOCK
→ Claude処理前に停止
→ 意図的切替は /task <target>(UserPromptSubmitのraw文字列 "/task" special-case判定)
を変更する。
新しい契約:
ordinary UserPromptSubmit
→ Task Contextでtargetを観測・分類
→ same/unbound/terminal等の既存合法routingは従来どおり
→ ACTIVE current Activity + different primary target
→ binding/rebind/claim mutationを行わない
→ mismatchをadvisoryとしてEventJournalへ必須記録する(optionalではない)
→ Claude prompt processingは必ず継続
→ Task Contextを理由にexit 2しない
UserPromptExpansion(command_name == "task")
→ Task Contextそのものを変更する明示command lifecycle
→ command_argsからtarget解決
→ successfulならatomic rebind
→ target validation / persistence / atomic rebind failureはcommand failureとして明示的に失敗可能
→ ordinary UserPromptSubmitのraw文字列 "/task" special-caseは廃止し、
`/task` state-changing authorityはUserPromptExpansion command lifecycleへ一本化する
Task Contextをordinary Claude workflowのadmission controllerとして使用しない。
Task Contextの目的は routing / display / mistake detection / state synchronization であり、Task Context自身の誤検知、hook lifecycle anomaly、DB/adapter failureによってClaude本体の作業を停止させない。
同時に、mismatch検出そのもの(mistake-detection capability)は維持する。advisory化はhard-blockの撤去であり、observabilityの撤去ではない。
Current Validated Scope
- 実装: 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 で
UserPromptSubmitdeterministic classifierとwrong-primary hard blockが実装済み。 - current
scripts/task-context/task_context_hook_flows.pyはACTIVE different-primary branchでdecision: block,reason_code: different_primary_target_activeを返し、_record()でstatus="block"のEventJournalエントリを記録してからblockを返す。 - current
.claude/hooks/task_context/hook_entry.pyはordinaryUserPromptSubmitでもserviceのdecision == blockをexit 2へ変換する。/task(classification_kind == "SLASH_TASK"、.claude/hooks/task_context/classifier.pyの_SLASH_TASK_REによるraw prompt文字列の正規表現判定)はtransport failure時も例外的にfail-closedにする現行のcarve-outを持つ。 - current
.claude/skills/task/SKILL.mdは「UserPromptSubmithook adapterが、slash command expansionより前にraw prompt文字列として渡された/task ...をdeterministicにspecial-case判定する」と明記している。 - current
docs/dev/hook-boundaries.mdのhook_boundaries_manifest_v1にはhandler_id: hook_entry/event: UserPromptSubmitのentryが存在し、classification: blocker、fail_policy: fail_closed、script_exit_contract.block: 2、claude_event_semantics.exit_2_effect: blocks_prompt_submissionを固定している(scripts/check_hook_boundaries.pyがこのmanifestと.claude/settings.jsonのdriftを検出する。2026-09-10 readback時点でdrift なし)。 - Claude Code公式Hooksリファレンス(2026-09-10確認)では、
UserPromptSubmitのdecision:block/exit 2はprompt処理自体を停止し、UserPromptExpansionはuser-typed slash/skill commandが展開される時にのみ発火しcommand_name/command_args等のペイロードを受け取る、という両hookは別イベントとして現に存在する。 - current
.claude/settings.jsonのUserPromptSubmit登録はhook_entry.py UserPromptSubmitのみで、UserPromptExpansionの登録は存在しない(新規追加が必要)。 - upstream [BUG] UserPromptSubmit hook fires when Task/subagent completes instead of only on user prompt submission anthropics/claude-code#16952 ではTask/SubAgent completion時にも
UserPromptSubmitが発火する再現報告があり、2026-09-10時点でCLOSED状態である。upstream fixの有無・closeの詳細な経緯を本Issueのcorrectness前提にしない。 - hook inputだけから「physical human submit」と「internal completion/injected turn」を完全かつ将来互換に区別できると仮定しない。
Remaining Parent Gaps
本Issueが塞がない #2562 の Remaining Parent Gaps(2026-09-10時点):
- 依存順での最終Child Issues(実装: Task ContextにTask-aware cross-session messaging guardとcross-Task Herdr control guardを追加する #2566, 実装: Herdr cold restartでTask BindingとNative/Claude-GPT runtime flavorを自動復元する #2569, #2571等)のdelivery完了(本Issueのscope外)
- 検証: Task Context v1統合runtime acceptanceをNative/Claude-GPT/Herdrで実証する #2570 integrated runtime acceptancePASSとparent AC evidence mappingの取得(本Issueのscope外)
- 調査: Herdr cold restart経路のproject-scoped dispatcher/PATH-shim interception実現可能性spike #2571(Herdr cold restart capability spike)の判定結果を#2569の設計判断へ反映すること(本Issueのscope外)
- refinementで新規materializeされたcapability-spike/follow-upのparent closure planへの反映(本Issue由来のfollow-upが生じた場合は別途対応)
Outcome
Task Contextはwrong-primary suspicionを検出できるが、その検出だけを理由にordinary Claude promptを停止しない。
high-confidence mismatch時は:
- current Task/Activity/Bindingを変更しない
- target refをclaimしない
- silent rebindしない
- mismatch diagnostic/eventをEventJournalへ必須で記録する(best-effortのUI Attention投影は任意でよい)
- Claude本体は通常どおり処理を継続する
- Task Context advisoryはSpark/Auto等の既存permission semantics(grant/deny/consume/defer/carry-over)に一切介入しない。元のpromptに含まれるdirectiveの意味論はSpark/Auto自身に完全委譲する。
explicit /task <target>は、UserPromptExpansion(command_name == "task")経由のcommand lifecycleとして、Task Context stateを変更する既存の明示failure semanticsを維持する。
In Scope
1. UserPromptSubmit service decision
scripts/task-context/task_context_hook_flows.py のACTIVE different-primary branchを変更する。
旧:
decision = block
reason_code = different_primary_target_active
status = block(EventJournal)
新:
decision = pass
reason_code = different_primary_target_active
advisory = true
binding mutation = none
task/activity transition = none
ref claim mutation = none
EventJournal status = pass 相当の non-blocking observation(必須記録)
EventJournalへの記録は必須であり、hard-block stateとして扱わず、non-blocking mismatch observationであることが分かるcontractにする。大規模な新schema/ledgerは追加しない。既存の_record()呼び出し箇所を維持し、渡すstatus値だけをblockからpass相当のnon-blocking値へ変更する。
2. Adapter-level double fail-open invariant
.claude/hooks/task_context/hook_entry.py に二重のfail-openを固定する。
ordinary UserPromptSubmitではTask Context由来のexit 2を禁止する。
service側が将来のregression/version skewで予期せず decision: block を返しても:
classification_kind != SLASH_TASK
→ diagnosticは残してよい
→ exit 0
→ Claude processing continues
とする。
これによりservice層の単一regressionだけでhard blockが再導入されないようにする。
3. /task state-changing authorityを UserPromptExpansion へ分離する
現行の /task は UserPromptSubmit hook内でraw prompt文字列(_SLASH_TASK_RE)をclassifierがspecial-case判定し、それを根拠にstate-changing authorityとしている。これは本Issue自身の前提(「hook inputだけからphysical human submitとinternal completion/injected turnを完全には区別できない」)と、ordinary promptにだけraw文字列不信任を適用し/taskにだけ適用しない、という非対称な扱いになり両立しない。
Claude CodeにはUserPromptExpansionという、user-typed slash/skill commandが展開される時にのみ発火する専用lifecycle eventが存在し、command_name/command_args等の構造化ペイロードを受け取れる。/taskは.claude/skills/task/SKILL.mdが定義するrepository-owned skillとして既に存在する。
新しい構造:
UserPromptSubmit
ordinary prompt
/task-looking text
↓
Task Context admission decisionとしては常に fail-open
mismatch detection / autobind / legal routingのみ
ordinary pathから exit 2 は絶対に出さない
UserPromptExpansion
matcher = task
↓
command_name == "task"
command_argsからtarget解決
↓
atomic /task rebind
↓
success → expansion continues
target validation / persistence failure → /task commandだけblock
.claude/settings.jsonへUserPromptExpansion(matcher: task)のhook登録を追加し、.claude/hooks/task_context/hook_entry.pyにこのイベント用のentry pointを追加する。.claude/hooks/task_context/classifier.pyの_SLASH_TASK_REによるraw prompt文字列special-case判定はordinary UserPromptSubmitのstate-changing authorityとしては使用しなくなる(UserPromptSubmit側のclassifierをそのまま流用してtarget解析ロジックを再実装しないことは許容する。authorityの所在だけを移す)。
新daemon、LLM classifier、network lookup、authorization frameworkは追加しない。
4. Existing useful routingは維持
以下は後退させない。
- UNBOUND → ordinary Issue/PR prompt autobind
- provisional/absorbent Task → first primary ref absorb
- same target → pass
- REFERENCE_ONLY → pass
- AMBIGUOUS → pass / no silent rebind
- terminal Activity → ordinary promptによるlegal advance/rebind
/clear//quitrecovery- statusLine / Herdr projection
5. ACTIVE mismatch時のstate safety
ACTIVE Task A中にTask Bらしきordinary promptを観測しても:
Claude execution: continue
Task A Binding: unchanged
Task B claim: not created by mismatch branch
Task Bへのsilent rebind: prohibited
Task AへのB由来workflow completion誤適用: prohibited
workflow signalがsession-originと整合しない場合はTask Context syncを deferred / conflict 等にできるが、workflow producer本体の成功をrollbackしない。
6. Advisoryで実質blockを再導入しない
mismatch検出時にClaudeへ「作業を止めろ」「人間承認を待て」「/taskまで続行するな」等のinstructionをadditionalContext等で注入し、exit 2の代わりに実質的なblockを再現してはならない。
必要ならdiagnostic/event/statusLine/Herdr/Attention等のnon-blocking presentationで扱う。
7. Task Context advisoryはSpark/Auto permission semanticsに介入しない
Task Context mismatch advisory自体は、Spark/Auto authorizationを以下のいずれについても変更しない。
mismatch advisory自体は
Spark/Auto authorizationを
grantしない
denyしない
consumeしない
deferしない
carry-overを生成しない
元のpromptに含まれるdirectiveの意味論は
Spark/Auto自身に完全委譲する
「mismatchだからdirectiveをconsumeさせない」のような新しいpermission policyをTask Contextに作らない。advisory-only化後、その ordinary prompt は実際にClaudeへ渡るため、人間が実際にSpark directiveを含むpromptを送ったならSpark側が通常どおりそのdirectiveを処理するのは正当である。
8. Contract cascade
本Issueのowner decisionをcurrent canonical behaviorとして、open child/verification contractを整合させる。historical #2564(CLOSED)とmerged PR #2615は成功した記録として書き換えない。
- 導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562: Goal / Desired Destination / AC4 に残る「ACTIVEな別primary target誤配送はClaudeが処理する前にblock」という記述を、「advisory + no silent rebind + ordinary workflow continues」へ更新する。
- 実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565: Current Validated Scope および In Scope 中の「ACTIVEな異なるprimary target → block」という既存guard前提の記述と AC4 を、「bindingをsilentに変更せず、必要なTask Context syncはdeferred/conflict、producer workflowは継続」へ整合させる。
- 実装: Claude-GPTをcanonical Task Context DBとoperator runtime profileへ統合する #2567: AC7「Task ContextにblockされたSpark directive付きpromptのauthorizationが次turnで使用不能」を、「advisory mismatchがSpark/Auto permission semanticsへ一切介入しない(grant/deny/consume/defer/carry-overのいずれも行わない)」ことを固定するcontractへ更新する。In Scope中の該当記述も同様に更新する。
- 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568: AC7「synthetic Task fixtureでUserPromptSubmit primary-target mismatchをactual fresh Claude runtime上でblockできる」を、「advisoryとして観測でき、Claude processingは継続し、Binding/Activity/claimが不変であることを実際のfresh Claude runtime上で確認できる」へ更新する。
- 検証: Task Context v1統合runtime acceptanceをNative/Claude-GPT/Herdrで実証する #2570: In Scope中の「ACTIVE different-primary prompt → pre-processing block」と AC2 を、「ACTIVE different-primary prompt → advisory observation、Claude processing継続、Binding不変」へ更新する。
contract cascadeは、historical #2564 / merged PR #2615 の記録を除き、open/canonical contract(#2562/#2565/#2567/#2568/#2570)に「ordinary different-primaryをClaude processing前にblockする」normative requirementが残っていない状態まで、このfixがmergeする前に整合させる。
Out of Scope
- classifierをLLM化すること
- ordinary UserPromptSubmit hot pathへのnetwork/LLM lookup追加
- Task Contextをsecurity sandbox化すること
- ACTIVE mismatchで自動的に別Taskへrebindすること
- raw prompt/transcriptをDBへ保存すること
/taskexplicit commandのfailureをfail-openにすること- #2566のcross-Task
SendMessage/ HerdrPreToolUseASK/DENY policyを本Issueの理由だけで弱めること - daemon / message bus / generic authorization framework追加
- Claude Codeのcustom slash command機構(
.claude/commands/*.md)としての/taskの再実装
Acceptance Criteria
- AC1: ACTIVE Task A中にdifferent high-confidence primary target Bを含むordinary UserPromptSubmitを処理しても
decision: passとなり、Task AのBinding/Activity/claimsは不変、Task Bへのsilent rebind/claimは発生しない。 - AC2: AC1の結果は
different_primary_target_active相当のdiagnostic reasonとnon-blocking advisoryをEventJournalへ必須で記録する(optionalではない)。 - AC3: non-
/taskUserPromptSubmitでは、serviceが予期せずdecision: blockを返すfixtureでもhook_entry.pyのprocess exitは0となり、Claude prompt processingをTask Contextがhard blockしない。 - AC4: SubAgent/Task completion由来を模したUserPromptSubmit入力に別Issue/PR refが含まれてもexit 2にならず、current Bindingを変更しないregression testが存在する。
- AC5: 人間が実際に別primary targetのordinary promptを送った場合もhard blockせず、current Bindingをsilent rebindしない。
- AC6:
/task <target>のstate-changing authorityはUserPromptExpansion(command_name == "task"、command_argsからtarget解決)へ移り、validなら atomic rebindでき、invalid/unavailable/persistence failureでは/taskcommand自体の明示failure semanticsを維持する。ordinaryUserPromptSubmitはraw文字列/taskspecial-caseをstate-changing authorityとして使用しない。 - AC7: UNBOUND autobind、provisional absorb、same-target、REFERENCE_ONLY、AMBIGUOUS、terminal rebindの既存behaviorに回帰がない。
- AC8: raw prompt/transcriptはTask Context DB/EventJournalへ新規永続化されない。
- AC9: Task Context mismatch/sync failureだけを理由にworkflow producer本体をfailure/rollbackしない。
- AC10: 導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562/実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565/実装: Claude-GPTをcanonical Task Context DBとoperator runtime profileへ統合する #2567/実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568/#2570のopen/canonical contract(historical 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564・merged PR #2615を除く)に「ordinary different-primary promptをClaude処理前にblockする」normative requirementが残っていないことを確認できる。
- AC11: Task Context mismatch advisoryはSpark/Auto directiveのauthorization(grant/deny/consume/defer/carry-over)に一切介入せず、元のpromptに含まれるdirectiveの意味論はSpark/Auto自身に完全委譲される。
- AC12: real Native Claude runtimeでACTIVE different-primary ordinary promptを投入してもClaude processingが継続し、Binding不変・silent rebindなしを確認する。
- AC13: actual SubAgent completion結果に別Issue/PR targetらしいrefが含まれるscenarioで、UserPromptSubmitが誤発火する挙動がそのClaude Codeバージョンで再現するならexit 0でparent workflowが継続しBinding不変・no claim/no rebindであることを確認する。誤発火が再現しないバージョンでは
not_reproduced_on_this_versionとして記録してよく、それ自体をfailureにしない。ただしadapterのfail-open invariant自体のdeterministic testはAC3/AC4として必須のままとする。
Verification Commands
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC10
# AC11
# AC12
# AC13
$ uv run --locked pytest tests/task-context/test_hook_flows_user_prompt_submit.py -q
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC10
# AC11
# AC12
# AC13
$ uv run --locked pytest tests/task-context -q
$ uv run --locked pytest tests/test_hook_boundaries_doc.py -q
# preflight-scope: pr_review_only
$ uv run --locked python3 scripts/check_hook_boundaries.pyhook adapter専用testが別fileに存在する場合はcurrent mainをreadbackして canonical testも実行する。docs/dev/hook-boundaries.mdのmanifest更新後はscripts/check_hook_boundaries.pyがdrift 0件を返すことを実装完了条件に含める。
Runtime Verification Applicability
decision: immediate
applicable_acs:
- AC12
- AC13
reason: "本不具合はClaude Code actual UserPromptSubmit lifecycleでworkflowを停止したruntime regressionであり、fixtureだけではhard-block廃止の最終証明にしない。実際に壊れた経路はhuman ordinary promptそのものではなくSubAgent completion delivery経由であるため、両方のscenarioを分離して検証する。"
execution_environment:
- Native Claude Code
- Herdr managed operator session
- isolated Task Context test state where practical
artifact_requirements:
- claude --version
- current main SHA
- before/after Task/Activity/Binding identity
- hook decision/exit summary
- AC12: 人間が実際に送信したordinary mismatched promptをClaudeが処理した証跡
- AC13: actual SubAgent completionイベントの発生証跡と、誤発火有無・`not_reproduced_on_this_version`判定の記録
skip_conditions:
- "Claude Code CLI(`claude`)が利用できない、または認証済みセッションを起動できない環境では、live UserPromptSubmit / SubAgent completion 経路の実行そのものが不可能なため SKIP(exit 77)とし、fixture-only な PASS を fabricate しない"
- "isolated Task Context test state を用意できない共有環境では、当該部分のみ `not_reproduced_on_this_version` として記録し、AC12/AC13 の証跡取得自体は別途 skip_conditions を満たす環境で再試行する"
fallback_policy:
fallback_success_is_pass: falseAllowed Paths
.claude/hooks/task_context/**scripts/task-context/**tests/task-context/**docs/dev/task-context.mddocs/dev/hook-boundaries.md.claude/settings.json.claude/skills/task/SKILL.mdtests/test_hook_boundaries_doc.py
GitHub Issue contract cascadeはrepository filesystem Allowed Pathsとは別に、#2562/#2565/#2567/#2568/#2570の整合更新として扱う。
Stop Conditions
- ordinary UserPromptSubmitを再びhard-blockしないと成立しない設計になった場合
- mismatch解消のためACTIVE Taskへのsilent auto-rebindが必要になった場合
- raw prompt/transcript永続化が必要になった場合
- LLM/networkを通常UserPromptSubmit hot pathへ常時追加する必要が生じた場合
- Task Contextをsecurity boundaryへ昇格しないと成立しない場合
/task以外のordinary promptへ新たなhuman approval stepを要求する場合- #2566等の独立したtool-level permission/isolation policyを本Issueの便宜だけで弱める必要がある場合
- daemon / persistent poller / message busが必要になった場合
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- Claude Code hooks公式仕様(
UserPromptSubmit/UserPromptExpansion)の一次資料読解
Required Design References
- 導入: Herdr / Claude Code Task Contextで安定識別・誤操作防止・Attention Managementを実現する #2562
- 実装: Task Context v1のSQLite registry・schema・typed internal APIを追加する #2563
- 実装: 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
- 実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565
- 実装: 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
docs/dev/task-context.mddocs/dev/hook-boundaries.md.claude/hooks/task_context/hook_entry.py.claude/hooks/task_context/classifier.pyscripts/task-context/task_context_hook_flows.py.claude/skills/task/SKILL.md.claude/settings.jsonscripts/check_hook_boundaries.py- Claude Code Hooks Reference
- [BUG] UserPromptSubmit hook fires when Task/subagent completes instead of only on user prompt submission anthropics/claude-code#16952
Delivery Rule
1 Issue = 1 PR- current mainをfresh readbackしてから実装する
- classifier精度改善だけでcloseしない
- final proofは「ordinary mismatchがClaude処理を停止しない」ことと「
docs/dev/hook-boundaries.mdのdriftが0件であること」を含む
Activity
squne121 commentedon Sep 10, 2026
結論
判定: REQUEST_CHANGES。方向転換そのものは正しいですが、#2625 はまだ implementation-ready ではありません。
今回の runtime incident に対して、「Task Context は routing/display/mistake detection であり、ordinary
UserPromptSubmitの admission controller にしない」「mismatch は Binding を変えず advisory に落とす」「producer workflow は Task Context 同期失敗で巻き戻さない」という方針は適切です。現行実装は ACTIVE different-primary で service がdecision: blockを返し、adapter がそれを exit 2 に変換しているため、修正対象も正しく特定できています。Claude Code 公式仕様でも
UserPromptSubmitの exit 2 は prompt processing 自体を block します。一方、実際に Task/SubAgent completion でUserPromptSubmitが誤発火する upstream #16952 は再現付きで報告され、現在 Closed as not planned です。つまり「将来 upstream が直すから hard block を維持」という設計は成立しません。 (Claude)ただし、敵対的に読むと以下を直す必要があります。
Severity | Finding | 推奨 -- | -- | -- BLOCKER | canonical hook-boundaries が更新scopeから漏れている | docs/dev/hook-boundaries.md を Allowed Paths / Required References に追加 BLOCKER | 「explicit human /task」を、問題のある UserPromptSubmit の文字列判定で識別し続けている | /task state mutation を UserPromptExpansion(command_name=task) へ移す HIGH | mismatch EventJournal 記録が任意になっている | reason=different_primary_target_active, status=pass の観測eventを必須化 HIGH | #2567 Spark cascade の新契約が permission semantics を逆に歪める恐れ | 「Task Context advisory は Spark/Auto state に影響しない」と定義 HIGH | AC11 が実際の SubAgent completion regression を十分再現しない | actual SubAgent completion を含む runtime canary を追加 MEDIUM | contract cascade が「ACを書き換える」だけでは不足 | parent/child の Goal・Outcome・In Scope・runtime scenario まで更新 MEDIUM | verification commands が canonical hook-boundary test を含まない | boundary checker/test を追加BLOCKER 1 —
docs/dev/hook-boundaries.mdが完全に漏れていますこれは単なる補助ドキュメントではありません。current main の
docs/dev/hook-boundaries.md自身が、hook の 責務・fail policy・exit-code contract の正本であり、Task Context のUserPromptSubmitを現在classification: blockerfail_policy: fail_closedblock: 2として固定しています。さらに説明表でも
different-primary-target guardが prompt submission を停止すると明記しています。#2625 の Allowed Paths は
docs/dev/task-context.mdまでしか含まず、docs/dev/hook-boundaries.mdがありません。このまま実装すると、という明白な contract drift が残ります。
PR #2615 では、この manifest と
.claude/settings.jsonの整合性を守るために checker 自体まで修正しており、tests/test_hook_boundaries_doc.pyも存在します。#2625 に最低限追加すべきものは次です。
Allowed Pathsにdocs/dev/hook-boundaries.md。Required Design Referencesに同ファイル。Verification にtests/test_hook_boundaries_doc.pyと既存 hook-boundary checker の canonical command を追加してください。root の test を変更する必要がなければ Allowed Paths まで広げる必要はありません。BLOCKER 2 —
/taskをUserPromptSubmitに残すのは、#2625 自身の前提と矛盾しますここが一番大きいです。
#2625 は正しく、
と認めています。
ところが
/taskだけは引き続き、同じUserPromptSubmitの raw prompt を classifier がSLASH_TASKと判定したことを根拠に state-changing authority とします。現行hook_entry.pyもまさにその実装です。つまり意味論として、
となっています。これは成立しません。
しかも現在の Claude Code には、この用途にもっと直接的な
UserPromptExpansionがあります。公式仕様では、user-typed command が prompt に展開される時だけ発火
command_namecommand_argscommand_sourceexpansion_type=slash_commandを受け取り、skill/custom command を名前で matcher できます。 (code.claude.com)
さらに重要なのは、loop-protocol 自身がすでに Claude Code 2.1.261 の実runtimeで
UserPromptExpansionを検証済みなことです。新技術を持ち込む話ではありません。runtime-smoke 資産にすでに nativeUserPromptExpansionevidence channel が存在します。そして
/task自身も repository-owned skill として存在し、「現在は UserPromptSubmit raw prompt を special-case する」と明記されています。推奨構造
私は #2625 でここまで直す方を推奨します。
これなら「ordinary workflow は絶対に止めない」と「明示的
/taskstate mutation は失敗を偽装しない」の境界が Claude Code native lifecycle 自体で分離されます。新daemon、LLM classifier、network lookup、authorization frameworkは不要です。むしろ今より単純になります。
この変更を採用する場合、#2625 の Allowed Paths に
.claude/settings.jsonと.claude/skills/task/SKILL.mdも追加する必要があります。HIGH — mismatch event は「残せる」ではなく「残す」にすべきです
#2625 は現在、
という optional contract です。
これは advisory-only 化すると弱すぎます。
たとえば Task A で人間が本当に Task B のpromptを誤送信した場合、
になります。これは今回の方針上正しいのですが、何の観測も残らなければ mistake detection layer としての価値まで消えます。
大げさな ledger は不要です。現行 mismatch branch はすでに
_record()を実行しています。今のstatus="block"を、等の明確な non-blocking observation に変えれば十分です。現在の event はまさに
status="block"を記録してから block を返しています。EventJournal記録は必須、UIへのAttention投影はbest-effortくらいが最小で有用です。
逆に
additionalContextで「別Taskです、停止してください」と Claude に命令するのは #2625 の禁止どおり避けるべきです。公式仕様ではUserPromptSubmitの stdout /additionalContextは Claude のcontextへ入るため、そこで擬似blockを作れば設計を元に戻しただけになります。 (code.claude.com)HIGH — #2567 の Spark/Auto 修正文言は変えた方がいいです
#2567 は現在、
をACにしています。
#2625 はこれを、
へ変える案ですが、後半の consume まで禁止するのは危険です。
advisory-only 化後は、その ordinary prompt は実際に Claude へ渡ります。人間が本当に Spark directive を含むpromptを送ったなら、Spark側が通常どおりそのdirectiveを処理するのは正当です。
Task Context がすべきなのは、
です。
つまり 「permission semantics を保護する」のではなく「Task Context がpermission semanticsへ介入しない」 をACにした方がよいです。これはユーザーの「ハーネスが通常workflowを邪魔しない」という方針にも一致します。
HIGH — real-runtime AC は incident path そのものも検証した方がよいです
AC11 は、
なので必要ですが、今回壊れた経路は 人間のordinary promptそのものではなく SubAgent completion delivery です。
upstream #16952 も Task/SubAgent completion時の誤発火を具体的に再現しています。しかも closed as not planned なので、runtime regression testの価値があります。 (GitHub)
AC11を分けるのを推奨します。
upstream のversionによって誤発火しなくなった場合は
not_reproduced_on_this_versionと記録すればよく、それを failure にする必要はありません。重要なのは adapter invariant が常に fail-open なことです。fixtureだけで「SubAgent由来を模した」とするより、今回の事故への regression proof としてかなり強くなります。
contract cascade はもっと機械的に潰すべきです
#2625 が #2562/#2565/#2567/#2568/#2570 を更新対象にしていること自体は正しいです。
ただし、旧hard-block contractはACだけではありません。
たとえば #2562 は Goal/Desired Destination/Decisions Fixed/AC4 で「wrong primaryを開始前に止める」を前提にしています。
#2565 も Current Validated Scope と signal routing の途中で
ACTIVE different primary → blockを前提にしています。#2568 は real smoke AC7 が直接「primary-target mismatchをactual fresh Claude runtime上でblock」となっています。
#2570 も Native runtime scenario とAC2に wrong-primary block を残しています。
したがって AC10 は、
だけでなく、
まで固定した方がよいです。
closed #2564 と PR #2615 は歴史として書き換えない、という #2625 の判断は正しいです。
外部仕様から見ても advisory-only は適切です
Claude Code は現在も、
UserPromptSubmitのdecision:block/ exit 2 をかなり強い primitive として扱っています。公式上は prompt processing を停止します。 (Claude)さらに2026年7月にも、VS Code/Cursor では block reason が見えず、prompt が「消えた/固まった」ように見えるという再現付き issue が報告されています。CLI/Herdr が主用途でも、routing補助のような非セキュリティ機能をこの primitive に依存させるUX上の利益は薄いです。 (GitHub)
逆に、
UserPromptExpansion、SubagentStop、TaskCompletedといった専用 lifecycle event は現在かなり充実しています。Task Context側で rawUserPromptSubmitを万能な lifecycle inference point にするより、native eventが存在する責務はnative eventへ寄せる方が今後のClaude Codeにも追従しやすいです。 (Claude)推奨する #2625 の着地点
大きなcontrol-plane再設計は不要です。私は次の差分まで入れれば APPROVE可能と判断します。
最重要なのは、ordinary
UserPromptSubmitを完全な advisory/fail-open surface にすることと、/taskauthority をUserPromptExpansionに分離することです。その上で canonicalhook-boundaries、EventJournal、child contract、runtime regressionを同期させる。この構成なら、今回の誤blockを直すだけでなく「同じ種類の lifecycle anomaly でまた作業が止まる」構造そのものを除去できます。一方、#2566 の cross-Task
## 結論SendMessage/ Herdr ASK/DENY、runtime-smoke isolation、secret boundary等までこのIssueを理由に弱める必要はありません。それらは actual tool/control boundary であり、今回問題になった ordinary conversational turn の admission blocking とは別物です。判定: REQUEST_CHANGES。方向転換そのものは正しいですが、#2625 はまだ implementation-ready ではありません。
今回の runtime incident に対して、「Task Context は routing/display/mistake detection であり、ordinary
UserPromptSubmitの admission controller にしない」「mismatch は Binding を変えず advisory に落とす」「producer workflow は Task Context 同期失敗で巻き戻さない」という方針は適切です。現行実装は ACTIVE different-primary で service がdecision: blockを返し、adapter がそれを exit 2 に変換しているため、修正対象も正しく特定できています。Claude Code 公式仕様でも
UserPromptSubmitの exit 2 は prompt processing 自体を block します。一方、実際に Task/SubAgent completion でUserPromptSubmitが誤発火する upstream #16952 は再現付きで報告され、現在 Closed as not planned です。つまり「将来 upstream が直すから hard block を維持」という設計は成立しません。 ([Claude]1)ただし、敵対的に読むと以下を直す必要があります。
hook-boundariesが更新scopeから漏れているdocs/dev/hook-boundaries.mdを Allowed Paths / Required References に追加/task」を、問題のあるUserPromptSubmitの文字列判定で識別し続けている/taskstate mutation をUserPromptExpansion(command_name=task)へ移すreason=different_primary_target_active, status=passの観測eventを必須化BLOCKER 1 —
docs/dev/hook-boundaries.mdが完全に漏れていますこれは単なる補助ドキュメントではありません。current main の
docs/dev/hook-boundaries.md自身が、hook の 責務・fail policy・exit-code contract の正本であり、Task Context のUserPromptSubmitを現在classification: blockerfail_policy: fail_closedblock: 2として固定しています。さらに説明表でも
different-primary-target guardが prompt submission を停止すると明記しています。#2625 の Allowed Paths は
docs/dev/task-context.mdまでしか含まず、docs/dev/hook-boundaries.mdがありません。このまま実装すると、という明白な contract drift が残ります。
PR #2615 では、この manifest と
.claude/settings.jsonの整合性を守るために checker 自体まで修正しており、tests/test_hook_boundaries_doc.pyも存在します。#2625 に最低限追加すべきものは次です。
Allowed Pathsにdocs/dev/hook-boundaries.md。Required Design Referencesに同ファイル。Verification にtests/test_hook_boundaries_doc.pyと既存 hook-boundary checker の canonical command を追加してください。root の test を変更する必要がなければ Allowed Paths まで広げる必要はありません。BLOCKER 2 —
/taskをUserPromptSubmitに残すのは、#2625 自身の前提と矛盾しますここが一番大きいです。
#2625 は正しく、
と認めています。
ところが
/taskだけは引き続き、同じUserPromptSubmitの raw prompt を classifier がSLASH_TASKと判定したことを根拠に state-changing authority とします。現行hook_entry.pyもまさにその実装です。つまり意味論として、
となっています。これは成立しません。
しかも現在の Claude Code には、この用途にもっと直接的な
UserPromptExpansionがあります。公式仕様では、command_namecommand_argscommand_sourceexpansion_type=slash_commandを受け取り、skill/custom command を名前で matcher できます。 ([code.claude.com]1)
さらに重要なのは、loop-protocol 自身がすでに Claude Code 2.1.261 の実runtimeで
UserPromptExpansionを検証済みなことです。新技術を持ち込む話ではありません。runtime-smoke 資産にすでに nativeUserPromptExpansionevidence channel が存在します。そして
/task自身も repository-owned skill として存在し、「現在は UserPromptSubmit raw prompt を special-case する」と明記されています。推奨構造
私は #2625 でここまで直す方を推奨します。
これなら「ordinary workflow は絶対に止めない」と「明示的
/taskstate mutation は失敗を偽装しない」の境界が Claude Code native lifecycle 自体で分離されます。新daemon、LLM classifier、network lookup、authorization frameworkは不要です。むしろ今より単純になります。
この変更を採用する場合、#2625 の Allowed Paths に
.claude/settings.jsonと.claude/skills/task/SKILL.mdも追加する必要があります。HIGH — mismatch event は「残せる」ではなく「残す」にすべきです
#2625 は現在、
という optional contract です。
これは advisory-only 化すると弱すぎます。
たとえば Task A で人間が本当に Task B のpromptを誤送信した場合、
になります。これは今回の方針上正しいのですが、何の観測も残らなければ mistake detection layer としての価値まで消えます。
大げさな ledger は不要です。現行 mismatch branch はすでに
_record()を実行しています。今のstatus="block"を、等の明確な non-blocking observation に変えれば十分です。現在の event はまさに
status="block"を記録してから block を返しています。EventJournal記録は必須、UIへのAttention投影はbest-effortくらいが最小で有用です。
逆に
additionalContextで「別Taskです、停止してください」と Claude に命令するのは #2625 の禁止どおり避けるべきです。公式仕様ではUserPromptSubmitの stdout /additionalContextは Claude のcontextへ入るため、そこで擬似blockを作れば設計を元に戻しただけになります。 ([code.claude.com]1)HIGH — #2567 の Spark/Auto 修正文言は変えた方がいいです
#2567 は現在、
をACにしています。
#2625 はこれを、
へ変える案ですが、後半の consume まで禁止するのは危険です。
advisory-only 化後は、その ordinary prompt は実際に Claude へ渡ります。人間が本当に Spark directive を含むpromptを送ったなら、Spark側が通常どおりそのdirectiveを処理するのは正当です。
Task Context がすべきなのは、
です。
つまり 「permission semantics を保護する」のではなく「Task Context がpermission semanticsへ介入しない」 をACにした方がよいです。これはユーザーの「ハーネスが通常workflowを邪魔しない」という方針にも一致します。
HIGH — real-runtime AC は incident path そのものも検証した方がよいです
AC11 は、
なので必要ですが、今回壊れた経路は 人間のordinary promptそのものではなく SubAgent completion delivery です。
upstream #16952 も Task/SubAgent completion時の誤発火を具体的に再現しています。しかも closed as not planned なので、runtime regression testの価値があります。 ([GitHub]2)
AC11を分けるのを推奨します。
upstream のversionによって誤発火しなくなった場合は
not_reproduced_on_this_versionと記録すればよく、それを failure にする必要はありません。重要なのは adapter invariant が常に fail-open なことです。fixtureだけで「SubAgent由来を模した」とするより、今回の事故への regression proof としてかなり強くなります。
contract cascade はもっと機械的に潰すべきです
#2625 が #2562/#2565/#2567/#2568/#2570 を更新対象にしていること自体は正しいです。
ただし、旧hard-block contractはACだけではありません。
たとえば #2562 は Goal/Desired Destination/Decisions Fixed/AC4 で「wrong primaryを開始前に止める」を前提にしています。
#2565 も Current Validated Scope と signal routing の途中で
ACTIVE different primary → blockを前提にしています。#2568 は real smoke AC7 が直接「primary-target mismatchをactual fresh Claude runtime上でblock」となっています。
#2570 も Native runtime scenario とAC2に wrong-primary block を残しています。
したがって AC10 は、
だけでなく、
まで固定した方がよいです。
closed #2564 と PR #2615 は歴史として書き換えない、という #2625 の判断は正しいです。
外部仕様から見ても advisory-only は適切です
Claude Code は現在も、
UserPromptSubmitのdecision:block/ exit 2 をかなり強い primitive として扱っています。公式上は prompt processing を停止します。 (Claude)さらに2026年7月にも、VS Code/Cursor では block reason が見えず、prompt が「消えた/固まった」ように見えるという再現付き issue が報告されています。CLI/Herdr が主用途でも、routing補助のような非セキュリティ機能をこの primitive に依存させるUX上の利益は薄いです。 ([GitHub]3)
逆に、
UserPromptExpansion、SubagentStop、TaskCompletedといった専用 lifecycle event は現在かなり充実しています。Task Context側で rawUserPromptSubmitを万能な lifecycle inference point にするより、native eventが存在する責務はnative eventへ寄せる方が今後のClaude Codeにも追従しやすいです。 ([Claude]1)推奨する #2625 の着地点
大きなcontrol-plane再設計は不要です。私は次の差分まで入れれば APPROVE可能と判断します。
最重要なのは、ordinary
UserPromptSubmitを完全な advisory/fail-open surface にすることと、/taskauthority をUserPromptExpansionに分離することです。その上で canonicalhook-boundaries、EventJournal、child contract、runtime regressionを同期させる。この構成なら、今回の誤blockを直すだけでなく「同じ種類の lifecycle anomaly でまた作業が止まる」構造そのものを除去できます。一方、#2566 の cross-Task
SendMessage/ Herdr ASK/DENY、runtime-smoke isolation、secret boundary等までこのIssueを理由に弱める必要はありません。それらは actual tool/control boundary であり、今回問題になった ordinary conversational turn の admission blocking とは別物です。squne121 commentedon Sep 10, 2026
推奨アクションは、対象コメントの指摘を原則すべて採用して #2625 を再精緻化です。特に
/taskauthority のUserPromptExpansionへの移管は採用価値が高いです。current main では.claude/settings.jsonが Task Context をUserPromptSubmitにのみ登録し、/taskの SKILL 自身も rawUserPromptSubmitspecial-case を正本としています。 一方、リポジトリにはすでにUserPromptExpansionの native runtime-smoke 資産があります。対象コメントの BLOCKER/HIGH/MEDIUM を反映し、
docs/dev/hook-boundaries.md、EventJournal、Spark/Auto 非介入、actual SubAgent completion canary、#2562/#2565/#2567/#2568/#2570 の normative contract cascade まで一貫させるのが妥当です。 Claude Code の現行公式仕様でもUserPromptExpansionはcommand_name/command_argsを持つ user-typed command 専用 lifecycle で、UserPromptSubmitexit 2 は prompt processing を停止します。([Claude]1)なお、現在のセッションが別の ACTIVE Task に bind されている場合、#2625 自身が修正対象としている hard block に引っかかる可能性があります。その場合だけ、以下を送る前に
/task #2625を単独の1ターンとして送信してください。現在 #2625 なら不要です。以下をそのまま Claude Code に渡す想定です。
squne121/loop-protocolの Issue #2625 を対象に、.claude/skills/issue-refinement-loopを canonical procedure に従って実行してください。対象 Issue:
#2625
今回の trusted human-context anchor:
#2625 (comment)
このコメントは今回の owner-selected human context として扱ってください。URL だけから origin を推測する unlabeled lane や agent-report lane ではなく、
preflight.run.with_human_contextを使う canonical trusted-human-context 経路を使用してください。既に Claude Code は auto mode で起動済みです。repo loop iteration の途中で人間承認・確認を求めないでください。
issue-refinement-loopのloop_iteration_approval_gate.default_required: falseに従い、needs-fix の各 iteration は自動継続してください。Claude Code 自体の permission mode を変更したり、--dangerously-skip-permissions等へ切り替えたりする必要はありません。今回の目的は、anchor comment の REQUEST_CHANGES を current main の実装・ドキュメント・関連 Issue contract・最新の Claude Code hook semantics と照合し、#2625 を implementation-ready な canonical contract にすることです。anchor comment の推奨は原則採用してください。ただし current main または現在の公式仕様に反することが判明した項目だけは、証拠を示した上で意味論的に同等以上の修正へ置き換えてください。単にコメントを転記するのではなく、Issue 全体の Goal / Decisions / In Scope / Out of Scope / Acceptance Criteria / Verification / Runtime Verification / Allowed Paths / Required Design References / contract cascade が相互に矛盾しない状態まで整えてください。
開始時に current main を fresh readback し、Issue #2625 本文・全コメント、および #2562、#2564、PR #2615、#2565、#2567、#2568、#2570 を確認してください。少なくとも
docs/dev/hook-boundaries.md、docs/dev/task-context.md、.claude/settings.json、.claude/skills/task/SKILL.md、.claude/hooks/task_context/hook_entry.py、.claude/hooks/task_context/classifier.py、scripts/task-context/task_context_hook_flows.py、関連 Task Context tests、hook-boundary checker/tests、既存 runtime-smoke のUserPromptExpansionevidence を確認してください。パスや canonical command を記憶や anchor comment だけから決めず、current main から readback してください。SubAgent を使用してください。まず
codebase-investigatorSubAgent に current main の Task Context hook architecture、/task現行経路、hook-boundaries manifest、EventJournal、related Issue contract drift、既存UserPromptExpansionruntime-smoke/test 資産、必要な exact Allowed Paths / verification commands を調査させてください。外部仕様が今回の design decision に直接影響するためweb-researcherSubAgent も使用し、現在の Claude Code Hooks Reference におけるUserPromptSubmit、UserPromptExpansion、SubagentStop、TaskCompleted、exit-code semantics と、anthropics/claude-code#16952 の現在状態を確認させてください。可能なら両者は並列実行して構いませんが、起動した SubAgent の完了を必ず待ち、全結果を回収・統合してから contract mutation と最終判断へ進んでください。未完了 SubAgent を残したまま次工程や終了報告へ進まないでください。canonical Step 2 review のために legacyissue-reviewerSubAgent を追加起動してはいけません。Step 2 の authority は現行 skill が定める root-ownedrun_root_review_pipeline.py produce/canonical_step2_routeに従ってください。anchor comment の BLOCKER である hook boundary drift は解消してください。
docs/dev/hook-boundaries.mdを #2625 の Allowed Paths と Required Design References に必要に応じて追加し、canonical manifest/checker と実装後 contract が矛盾しないよう Issue を修正してください。.claude/settings.jsonと.claude/skills/task/SKILL.mdも/tasklifecycle migration に必要なら Allowed Paths / Required References に明示してください。root test file 自体を変更する必要がない場合は、test を実行対象に加えるだけで不要な Allowed Paths 拡張はしないでください。/taskの state-changing authority は anchor comment の推奨どおり、rawUserPromptSubmit文字列から human intent を推測する設計から分離する方向を採用してください。current Claude Code が提供するUserPromptExpansionのcommand_name == task/command_argsを explicit command lifecycle として利用し、atomic/taskrebind をそこで所有する contract にしてください。ordinaryUserPromptSubmitは/taskらしい文字列を含む場合も含め Task Context admission surface として fail-open とし、Task Context 起因で ordinary prompt processing を exit 2 / decision:block にしないことを固定してください。ただし/taskcommand 自体の target validation・persistence・atomic rebind failure はUserPromptExpansioncommand lifecycle 内で明示 failure にできるよう維持してください。ACTIVE different-primary mismatch は
decision: pass、Binding/Activity/claim mutationなし、silent rebindなし、としてください。同時に mistake-detection capability を失わないよう EventJournal の non-blocking observation を optional ではなく canonical requirement にしてください。既存 EventJournal contract と整合する最小変更を選び、例えばreason_code: different_primary_target_activeと non-blockingstatus: pass相当を記録できるよう Issue contract を固定してください。raw prompt/transcript の新規永続化、大規模 ledger、新 daemon/message bus は導入しないでください。Task Context mismatch advisory は Spark/Auto permission semantics に介入しない、と明文化してください。Task Context advisory 自体が authorization を grant / deny / consume / defer / carry-over してはならず、元の ordinary prompt に Spark/Auto directive が含まれる場合の解釈は Spark/Auto 自身へ委譲してください。「mismatch だから directive を consume させない」のような新しい permission policy を Task Context に作らないでください。
runtime regression contract は human ordinary mismatch と actual SubAgent completion incident を分離して明確化してください。実人間が different-primary ordinary prompt を送った場合は Claude processing 継続・Binding 不変・claim/rebindなしを確認してください。さらに actual SubAgent completion を発生させ、completion result に別 target らしい ref が存在する scenario を canary として扱ってください。その Claude Code version で upstream anomaly が再現するなら Task Context adapter が exit 0 で parent workflow を継続することを証明してください。再現しない version なら
not_reproduced_on_this_version相当として記録してよく、runtime canary 自体を失敗扱いにしないでください。ただし deterministic adapter fail-open invariant の test は必須のままにしてください。contract cascade は AC の文言だけで済ませないでください。#2562/#2565/#2567/#2568/#2570 の current canonical/open contract を調査し、Goal、Desired Destination、Decisions、In Scope、Outcome、AC、runtime scenario、verification 等に残る旧
ordinary different-primary → pre-processing blocknormative requirement を洗い出してください。historical #2564 と merged PR #2615 は履歴として保持し、成功した過去を書き換えないでください。その上で #2625 の AC を、historical record を除く open/canonical contract に旧 hard-block requirement が残らないことまで検証可能な形にしてください。関連 Issue への実際の contract mutation/materialization が canonical issue-refinement workflow で必要と判定された場合は、その正規 lane に従って自動実行し、承認待ちで停止しないでください。controlled mutation lane を迂回した ad-hocgh issue edit等は使わないでください。#2566 の cross-Task
SendMessage/ Herdr ASK/DENY、secret boundary、runtime-smoke isolation 等の独立した tool/control boundary は今回の理由だけで弱めないでください。本 Issue の修正対象は ordinary conversational turn の Task Context admission blocking です。Verification には current main から取得した canonical Task Context tests に加え、
tests/test_hook_boundaries_doc.pyとscripts/check_hook_boundaries.pyの canonical checker invocation を含めてください。コメントに書かれたコマンド名を無条件に信用せず、current main の registry/docs/tests から正確な invocation を確定してください。mutation は
.claude/skills/issue-refinement-loopが定める canonical flow に従ってください。まずpreflight.run.with_human_context、必要な investigation / web research、trusted contract patch/update lane、rewrite、root-owned review pipeline、final readback/review を順に通してください。planner/reviewer の machine-readable decision を prose で再実装しないでください。review が
needs-fix / request_changesを返した場合、人間へ確認せず bounded refinement loop を継続してください。deterministic repair、structural repair、trusted-anchor full rewrite、必要な read-only SubAgent investigation など skill が許可する解消手段を尽くしてください。anchor comment ですでに owner decision が与えられている項目を再び「人間判断が必要」として差し戻さないでください。ただし current skill が canonical に
human_judgment_requiredと判定する真の未解決 owner ambiguity、environment/integrity failure、secret/credential へのアクセス要求、不可逆・破壊的操作が必要になる場合は勝手に意味を捏造せず停止してください。それ以外の通常の refinement、Issue body/comment mutation、contract cascade、verification では承認を求めないでください。最終的には #2625 を fresh readback し、anchor comment の各 BLOCKER/HIGH/MEDIUM finding がどの contract で解消されたか、残存 blocker がないか、canonical root review の terminal verdict、関連 Issue contract cascade の結果、SubAgent の完了確認、Web仕様確認結果を短く報告してください。issue-refinement-loop 自身が定める canonical completion/handoff routing はそのまま遵守し、独自の終了条件を追加しないでください。
この形なら、単なる「レビューコメントに従って本文を書き換える」ではなく、trusted anchor → repository/Web 調査 → contract update → canonical review → 再修正まで承認なしで回しつつ、canonical Step 2 の authority を壊さずに SubAgent を活用できます。
squne121 commentedon Sep 10, 2026
推奨アクションは、#2625 は再精緻化ではなく、そのまま
impl-review-loopの実装フェーズへ進めるです。現在の Issue 本文は、前回レビューの主要指摘である advisory-only 化、/taskauthority のUserPromptExpansion移管、EventJournal 必須記録、Spark/Auto 非介入、actual SubAgent completion canary、hook-boundary contract、関連 Issue cascade をすでに契約へ取り込んでいます。一方 current main の実装はまだ旧契約です。
hook_entry.pyは ordinaryUserPromptSubmitのdecision: blockを exit 2 に変換し、raw/task判定にも state-changing authority を持たせています。service 側も ACTIVE different-primary をstatus="block"/decision="block"としており、.claude/settings.jsonにUserPromptExpansionの Task Context hook はありません。つまり実装対象は明確です。また、現行
impl-review-loopの正常終端はAPPROVE+ live mergeabilityCLEAN/HAS_HOOKS+ blockers 空 →draft_pr_readyで、その時点ではPRをマージせず人間のマージ判断に渡す契約です。したがって今回の「マージ直前まで承認不要」と一致します。Step 1/2/4 はそれぞれimplementation-worker、test-runner、pr-reviewerSubAgent に委譲するのが canonical flow です。外部仕様上も設計は妥当です。現行 Claude Code では
UserPromptSubmitの block/exit 2 は prompt processing 自体を止める一方、UserPromptExpansionは command name で matcher でき、command_name/command_argsを構造化入力として受け取れます。([Claude]1) また upstream #16952 では SubAgent completion 時にUserPromptSubmitが発火した再現報告があり、現在は Closed as not planned なので、AC13 の実runtime canaryを残す価値があります。([GitHub]2)なお、今の対話セッションが別の ACTIVE Task に bind されている場合だけ、下のプロンプトより先に
/task #2625を単独ターンで送るのが安全です。すでに #2625 なら不要です。そのまま投入するプロンプトです。
squne121/loop-protocolの Issue #2625 を対象に、.claude/skills/impl-review-loopを current main の canonical procedure に従って実行してください。対象:
#2625
この対話セッションは既に auto mode で起動済みです。通常の実装・検証・レビュー・修正 iteration について人間の承認や確認を求めず、
impl-review-loopの canonical terminal state である merge 直前のdraft_pr_readyまで自律的に継続してください。PR は絶対に merge しないでください。auto-merge も有効化しないでください。最終到達点は、current-head review が APPROVE、blockers が空、必要な検証/CIが満たされ、live mergeability が skill の approved 条件を満たした状態までです。そこで停止し、人間に最終 merge 判断を渡してください。
max_iterationsは canonical default の 3 としてください。iteration 内で解決可能な REQUEST_CHANGES、stale head、BEHIND、通常の検証失敗、review fix は人間へ戻さず skill の routing に従って自動修正・再検証・再レビューしてください。開始時には必ず current main を fresh readback してください。手元の記憶、過去の contract snapshot、Issue 作成時点の SHA を current authority とみなさないでください。repo root、HEAD、dirty state、既存 worktree/branch/PR の有無を確認し、既存の #2625 implementation PR がある場合は duplicate PR を作らず canonical reuse/recovery route を選択してください。
impl-review-loopの Root-Owned Synchronous Entry Transition を省略しないでください。capability preflight → live Issue #2625 fetch → current-run issue-contract-review → live Issue再取得 → routing decision → 条件成立時のみ Step 1 起動、を同一の canonical entry transition として実行してください。Issue #2625 本文・全コメント、および少なくとも以下を current state で確認してください。
.claude/hooks/task_context/hook_entry.py.claude/hooks/task_context/classifier.pyscripts/task-context/task_context_hook_flows.py.claude/settings.json.claude/skills/task/SKILL.mddocs/dev/task-context.mddocs/dev/hook-boundaries.mdscripts/check_hook_boundaries.pytests/task-context/**tests/test_hook_boundaries_doc.pyUserPromptSubmit,UserPromptExpansion,SubagentStop,TaskCompleted#2625 の refined contract を implementation authority としてください。特に以下を落とさないでください。
UserPromptSubmitの ACTIVE different-primary mismatch はdecision: passとし、Claude processing を継続すること。different_primary_target_active相当の non-blocking advisory observation を EventJournal に必須記録すること。observability 自体を消さないこと。UserPromptSubmitへ誤ってdecision: blockを返しても、adapter-level invariant により Task Context 起因の exit 2 を出さず exit 0 とすること。additionalContext等で「停止しろ」「/task まで作業するな」「人間承認を待て」と命令し、実質的な hard block を再導入しないこと。/task <target>の state-changing authority を rawUserPromptSubmittext special-case からUserPromptExpansionの explicit command lifecycle へ移すこと。UserPromptExpansionではcommand_name == "task"とcommand_argsを利用し、valid target は atomic rebind、validation/persistence/rebind failure は/taskcommand 自体の明示的 failure とすること。.claude/settings.json、.claude/skills/task/SKILL.md、canonical hook-boundaries manifest/documentation を新しい lifecycle ownership と一致させること。/clear//quitrecovery、statusLine / Herdr projection を回帰させないこと。contract cascade については、#2562/#2565/#2567/#2568/#2570 に既に advisory-only 契約が反映されている箇所があるため、機械的に再編集しないでください。fresh readback して、historical #2564 / merged PR #2615 を除いた current open/canonical contract に「ordinary different-primaryをClaude processing前にhard blockする」という normative requirement が残っている箇所だけを特定し、#2625 AC10 に必要な controlled mutation を行ってください。historical record は書き換えないでください。
SubAgent を canonical skill contract に従って必ず使用してください。
Step 1:
implementation-workerSubAgent にimplement-issueを委譲してください。実際の Issue #2625、fresh Allowed Paths、current fix_delta、必要な technical recommendation を materialize して渡してください。Step 2:
implementation-worker 完了後、
test-runnerSubAgent に独立検証を委譲してください。Step 4:
current-head verification gate を通過した場合だけ
pr-reviewerSubAgent に current PR head の review を委譲してください。重要: SubAgent は起動しただけで完了扱いにしないでください。各 SubAgent を起動したら
.claude/skills/impl-review-loopの Common Completion Protocol に従い、terminal result が得られるまで必ず待機・joinし、結果を回収してから次ステップへ進んでください。複数 SubAgent を並列起動する場合も、必要な全 SubAgent の完了を待って全結果を統合してください。未完了・実行中の SubAgent を残したまま verification、review、最終報告へ進んではいけません。SubAgent 自身が返す単なる
human_review_required: trueboolean は、それだけを理由に即停止しないでください。現行impl-review-loopの Step 5 routing authority に従い、通常の fix/retry で解消可能なら継続してください。一方、canonicalHUMAN_REVIEW_REQUIREDverdict / route、actual Git conflict、live human veto、max_iterations 到達、Issue自身の真正な Stop Condition など、skill が明示する停止条件は迂回しないでください。実装後は Issue #2625 の Verification Commands を literal contract として current body から再取得し、少なくとも canonical に存在する以下を実行してください。
uv run --locked pytest tests/task-context/test_hook_flows_user_prompt_submit.py -quv run --locked pytest tests/task-context -quv run --locked pytest tests/test_hook_boundaries_doc.py -quv run --locked python3 scripts/check_hook_boundaries.pyhook adapter 専用の current canonical test file が別途存在する場合は、それも current main から discovery して実行してください。Verification Commands の名前やpathがcurrent repoと食い違う場合は勝手にPASS扱いせず、contract/current-main mismatchとして canonical loop 内で処理してください。
AC12 / AC13 の runtime verification も Issue contract に従って実施してください。
AC12:
real Native Claude runtime で ACTIVE different-primary ordinary prompt を扱い、Claude processing が継続し、Binding不変、silent rebind/claimなしであることを確認してください。
AC13:
actual SubAgent completion を発生させ、completion result に別 Issue/PR target らしい ref が含まれる scenario を canary としてください。その current Claude Code version で
UserPromptSubmitanomaly が再現する場合は exit 0、parent workflow継続、Binding不変、no claim/no rebind を証明してください。再現しない場合は Issue contract に従いnot_reproduced_on_this_versionと記録し、それ自体を failure にしないでください。ただし deterministic adapter fail-open tests を runtime非再現の代替に省略してはいけません。runtime verification では
claude --version、対象 current-main SHA、before/after Task/Activity/Binding identity、hook decision/exit summary 等の Issue が要求する evidence を public-safe に残してください。runtime を実行できない正当な skip condition に該当する場合、fixture-only success を runtime PASS に偽装しないでください。PR 作成後、Step 2 → Step 4 → Step 5 を canonical に回してください。review が REQUEST_CHANGES の場合は blockers を
fix_deltaとして次のimplementation-workerに渡し、修正 → verification → current-head review を再実行してください。PR head が変わったら以前の verification/review を stale として扱ってください。BEHIND の場合は canonical update-branch route、stale reviewed head の場合は current-head rereview route に従ってください。人間への途中承認依頼は不要です。既に auto mode なので permission mode 自体を変更したり、
--dangerously-skip-permissions等へ切り替えたりしないでください。secret/credential 取得、権限昇格、破壊的・不可逆操作、Issue/skill の真正な Stop Conditions は別であり、それらを「auto modeだから許可された」と解釈しないでください。完了条件は
.claude/skills/impl-review-loopのapprovedroute のみです。pr-reviewerverdict = APPROVEdocs/dev/hook-boundaries.mdと.claude/settings.jsonの canonical drift check が PASSこの状態で
IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready相当として終了してください。PR は merge しないでください。
最後に、PR URL、current head SHA、変更概要、Verification Commands結果、runtime AC12/AC13結果、current-head review verdict、live mergeability、未解決 blockers の有無、contract cascade確認結果、起動した各 SubAgent がすべて terminal completion 済みであることを短く報告してください。
このプロンプトでは、「承認不要」を permission boundary の無効化ではなく、
impl-review-loopが本来持っている自動 feedback loop を最後まで使う形にしています。特に #2625 は SubAgent completion が元の事故経路なので、「SubAgentを使う」だけでなく「completionを必ず待つ」と「AC13で実 completion pathを検証する」を両方固定するのが重要です。[-]修正: Task ContextのUserPromptSubmit wrong-session guardをadvisory-only化し通常workflowをhard blockしない[/-][+]実装: Task ContextのUserPromptSubmit wrong-session guardをadvisory-only化し通常workflowをhard blockしない[/+]squne121 commentedon Sep 10, 2026
root-owned entry router audit
route: stop
reason: review_verdict_blocked
squne121 commentedon Sep 10, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Sep 10, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Sep 10, 2026
implement-issue: 実装完了 (2026-09-10T16:21:23Z)
.claude/worktrees/issue-2625-advisory-only-task-contextworktree-issue-2625-advisory-only-task-contextnot_reproduced_on_this_versionとして記録(PR本文のRuntime Verification Evidence参照)feat: Task ContextのUserPromptSubmit wrong-session guardをadvisory-only…