Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2154"
goal_ref: "Claude Code を共通 development harness とし worktree-agent-runtime-smoke の SubAgent 実行 evidence を model 生成文字列でなく hook ID ベースの相関証拠で証明する"
change_kind: mixedParent Issue
Parent Goal Ref
- Goal: Claude Code を共通 development harness とし、Anthropic subscription と ChatGPT Pro Codex subscription を独立 runtime として並列運用できる状態へ移行し、Codex CLI 実行系を段階的に廃止する。
- Desired Destination:
worktree-agent-runtime-smoke共有 harness が、native Claude / claude-gpt launcher いずれの経路でも SubAgent 実行の因果性を model 出力に依存しない構造的証拠(hook ID 相関)で証明できる状態。
Current Validated Scope
- 本 Issue の write-capable scope は
scripts/agent-ops/run_worktree_agent_runtime_smoke.py/scripts/agent-ops/tests//docs/dev/runtime-verification-policy.md/.claude/skills/worktree-agent-runtime-smoke/SKILL.md/.claude/skills/worktree-agent-runtime-smoke/references/claude-code.mdに限定する。 SubagentStart/SubagentStopのagent_id相関、およびPreToolUse/PostToolUseの tool invocation ID 相関を用いた causal evidence 判定ロジックを追加し、marker 文字列の出力のみに基づく PASS 判定を置き換える。docs/dev/runtime-verification-policy.mdへ、SubAgent 実行の causal evidence 要件(hook ID 相関を要求し marker 文字列単独では不十分とする規約)を追記する。scripts/claude-gpt/側(launch.sh 本体・narrow observability channel)の実装は Issue 実装: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2158 / PR feat: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2162 の scope であり、本 Issue では変更しない。
Remaining Parent Gaps
- Child 2(実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160)・Child 3(実装: retire Codex CLI assets and documentation(Phase 3, Child 3 of #2154) #2161)は本 Issue の完了に依存しない。
- 本 Issue 完了後も、hook ID 相関 evidence を実際の live claude-gpt launcher 実行に対して再取得し記録する運用は、対象 Issue(実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 close 後の evidence 更新運用)側の責務として残る。
Outcome
scripts/agent-ops/run_worktree_agent_runtime_smoke.py に、SubagentStart/SubagentStop の同一 agent_id 相関・Agent tool call の invocation ID 相関・child transcript の存在と内容の相関・terminal completion を組み合わせた causal evidence 判定関数が追加され、marker 文字列(例: 完了を示す固定文字列)の出力のみでは PASS と判定されないことを示す hermetic regression test が PASS し、structured lane(因果性を hard gate とする)と interactive lane(因果性ではなく operability/multi-turn/session isolation を証明対象とする)の責務分離が契約・実装・docs に一貫して反映され、docs/dev/runtime-verification-policy.md に同要件が明文化されたコミットが作成された状態。
In Scope
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyに、extract_claude_hook_lifecycle_eventsが返すSubagentStart/SubagentStopイベント列から同一agent_idを持つ Start/Stop ペアの有無を判定する関数subagent_causal_evidence_verdict()を追加する。PreToolUse/PostToolUsehook payload に含まれる tool invocation を相関する ID(Claude Code hook payload のtool_use_id相当のフィールド)とAgenttool call のマッチングを行い、判定結果のフィールドtool_invocation_id_correlated(bool)としてsubagent_causal_evidence_verdict()の戻り値に含める。subagent_causal_evidence_verdict()の戻り値にcausal_evidence_sourceフィールド(enum:hook_id_correlated/marker_only_insufficient/no_evidence)を含める。hook_id_correlatedを返すのは、以下をすべて満たした場合に限る(いずれか一つでも欠落・不一致の場合はhook_id_correlatedへ昇格しない fail-closed 判定とする)。- 同一
agent_idのSubagentStartと terminal なSubagentStop(stop_reason相当のフィールドが取得できる場合はエラー・タイムアウト等の non-terminal 値でないこと)が同一実行(同一 stdout ストリーム・取得可能なら同一session_id)内に観測されること。 SubagentStoppayload のagent_transcript_path相当のフィールドが取得でき、tool_invocation_id_correlated == True(対応するAgenttool call の invocation ID 相関が成立していること)であること。--expect-marker等で期待成果物・marker 文字列の照合を要求する呼び出しにおいては、その期待値が 相関済み child の transcript /last_assistant_message相当のフィールド由来であることを追加確認し、parent 自身の最終応答文字列のみに一致した場合はhook_id_correlatedとしない。
- 同一
- lane separation: structured lane(
run_structured_claude経由、--include-hook-eventsの stream-json チャンネルが構造的に利用可能)は、呼び出し側が--expect-marker等で SubAgent 実行結果の照合を要求する場合、causal_evidence_source == "hook_id_correlated"を PASS の必要条件として要求する(既定強制。追加フラグ不要)。interactive lane(run_interactive_herdr_isolated経由、herdr pane のテキストレンダリングには--include-hook-eventsの hook payload が構造的に現れない)は、Skill/SubAgent の因果性証明を hook evidence に依存させず、既存の operability / multi-turn / session isolation の証拠(Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 で追加された Herdr session baseline 比較等)を PASS 条件として維持する。interactive lane で causal hook evidence の追加確認を要求したい呼び出し元向けに、--require-subagent-causal-evidence相当の opt-in フラグを提供してよい。marker 文字列判定は両 lane で補助情報として残してよいが単独で PASS 判定に用いない。 SubagentStartのみが観測され対応するSubagentStopが観測されない場合(既存のCHILD_TERMINAL_STATUS_ASYNC_NO_STOP相当のケース)、hook イベントが一切観測されず marker 文字列のみが出力された場合、SubagentStart/SubagentStopのagent_idが不一致の場合、tool_invocation_id_correlated == Falseの場合、agent_transcript_pathが欠落または実在しない/内容が相関しない場合、無関係な SubAgent が正常終了した後に parent model 自身が completion marker を出力した場合、のそれぞれでcausal_evidence_sourceがhook_id_correlated以外(no_evidenceまたはmarker_only_insufficient)になることを検証する hermetic regression test(合成 stdout fixture ベース、live 実行不要)を追加する。docs/dev/runtime-verification-policy.mdの「10. worktree-agent-runtime-smoke」セクション付近に、SubAgent 実行の causal evidence は hook ID 相関(Start/Stop agent_id 一致・tool invocation ID 相関・child transcript 由来の成果物確認・terminal completion)を要求し marker 文字列単独では不十分とする規約、および structured/interactive lane の責務分離を追記する。.claude/skills/worktree-agent-runtime-smoke/SKILL.mdおよびreferences/claude-code.mdに、subagent_causal_evidence_verdict()の利用方法・causal_evidence_sourceの意味・lane ごとの既定挙動を追記する。
Out of Scope
--claude-binlauncher 選択入力そのものの実装(Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 / PR 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加する (#2174) #2176 で完了済み)。scripts/claude-gpt/launch.sh本体・CLAUDE_GPT_RUNTIME_SMOKE_HOOKSnarrow observability channel の実装変更(Issue 実装: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2158 / PR feat: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2162 の scope)。- claude-gpt launcher に対する新規 live 実機検証の実施・evidence 再取得(本 Issue は判定ロジックとその hermetic regression test の追加に限定し、live 実行が必要な evidence 再取得は対象 Issue 側の運用に委ねる)。
- Codex CLI 向けの同等 causal evidence 基盤の追加。
PreToolUse/PostToolUse全般の新しい hook 設定・.claude/settings.jsonの hooks 定義変更(既存の--include-hook-events経由の scoped hook 注入の枠組みを変更しない)。- interactive lane(Herdr 経由)に対して structured lane 相当の hook payload を人工的に転記・偽装する仕組みの新設(herdr pane の構造的制約自体を変更する取り組みは別 Issue の scope とする)。
Acceptance Criteria
- AC1:
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyに関数subagent_causal_evidence_verdict()が定義されている。 - AC2:
subagent_causal_evidence_verdict()の戻り値にcausal_evidence_sourceフィールドが含まれる。 - AC3:
subagent_causal_evidence_verdict()の戻り値にtool_invocation_id_correlatedフィールドが含まれ、tool_invocation_id_correlated == Falseの場合はcausal_evidence_sourceがhook_id_correlatedにならない(判定結果に実効性がある)。 - AC4:
SubagentStartのみ観測(SubagentStop欠落)の合成 stdout fixture を入力した場合にcausal_evidence_sourceがhook_id_correlated以外(no_evidenceまたは既存のCHILD_TERMINAL_STATUS_ASYNC_NO_STOP相当の否定的な値)を返すことを検証する hermetic regression test が追加されている。 - AC5: hook イベントが一切観測されず marker 文字列のみが出力された合成 stdout fixture を入力した場合に
causal_evidence_sourceがmarker_only_insufficientを返すことを検証する hermetic regression test が追加されている。 - AC6: 追加した causal evidence regression test が
pytestで PASS する。 - AC7:
docs/dev/runtime-verification-policy.mdに、SubAgent 実行の causal evidence は hook ID 相関を要求し marker 文字列出力のみでは不十分とする規約が追記されている。 - AC8:
.claude/skills/worktree-agent-runtime-smoke/SKILL.mdにsubagent_causal_evidence_verdict()の利用方法が追記されている。 - AC9: structured lane(
run_structured_claude経由)は--expect-marker指定時、causal_evidence_source == hook_id_correlatedを追加フラグなしで PASS の必要条件として要求する(既定強制)ことを検証する hermetic regression test が追加されている。 - AC10: interactive lane(
run_interactive_herdr_isolated経由)は、既存の operability / multi-turn / session isolation の証拠を PASS 条件として維持し、causal hook evidence を既定で要求しない(--require-subagent-causal-evidence相当の opt-in 時のみ要求する)ことがコード・テストで確認できる。 - AC11:
SubagentStart/SubagentStopのagent_idが一致するがagent_transcript_pathが欠落・空・実在しない、または期待される marker/成果物がその transcript /last_assistant_message相当のフィールド由来であると確認できない合成 fixture を入力した場合に、causal_evidence_sourceがhook_id_correlatedにならないことを検証する hermetic regression test が追加されている。 - AC12: 無関係な SubAgent(別の
agent_id、期待成果物と無関係な transcript)が正常に Start/Stop し、期待 marker 文字列が parent model 自身の最終応答テキストにのみ出現するケースを合成 stdout fixture で再現し、PASS/hook_id_correlatedにならないことを検証する negative control regression test が追加されている。 - AC13:
.claude/skills/worktree-agent-runtime-smoke/references/claude-code.mdにsubagent_causal_evidence_verdict()/causal_evidence_source/ lane ごとの既定挙動に関する causal-evidence documentation が追記されている。
Verification Commands
# AC1
# baseline-expect: fail
$ rg -n "def subagent_causal_evidence_verdict" scripts/agent-ops/run_worktree_agent_runtime_smoke.py# AC2
# baseline-expect: fail
$ rg -n "causal_evidence_source" scripts/agent-ops/run_worktree_agent_runtime_smoke.py# AC3
# baseline-expect: fail
$ rg -n "tool_invocation_id_correlated" scripts/agent-ops/run_worktree_agent_runtime_smoke.py# AC4
# baseline-expect: fail
$ rg -n "def test.*subagent_start_without_stop" scripts/agent-ops/tests# AC5
# baseline-expect: fail
$ rg -n "marker_only_insufficient" scripts/agent-ops/tests# AC6
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -v# AC7
# baseline-expect: fail
$ rg -n "hook ID 相関" docs/dev/runtime-verification-policy.md# AC8
# baseline-expect: fail
$ rg -n "subagent_causal_evidence_verdict" .claude/skills/worktree-agent-runtime-smoke/SKILL.md# AC9
# baseline-expect: fail
$ rg -n -e "def test.*expect_marker.*default" -e "def test.*structured.*default.*causal" -e "def test.*default.*require.*causal" scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py# AC10
# baseline-expect: fail
$ rg -n -e "def test.*interactive.*causal.*opt.?in" -e "def test.*herdr.*causal_evidence" scripts/agent-ops/tests# AC11
# baseline-expect: fail
$ rg -n -e "def test.*transcript.*not_correlated" -e "def test.*transcript.*content" scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py# AC12
# baseline-expect: fail
$ rg -n -e "def test.*unrelated_subagent" -e "def test.*parent.*marker" scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py# AC13
# baseline-expect: fail
$ rg -n "causal_evidence_source" .claude/skills/worktree-agent-runtime-smoke/references/claude-code.mdAllowed Paths
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyscripts/agent-ops/tests/(新規テストファイルtest_run_worktree_agent_runtime_smoke_causal_evidence.pyを含む既存テストの更新を許容)docs/dev/runtime-verification-policy.md.claude/skills/worktree-agent-runtime-smoke/SKILL.md.claude/skills/worktree-agent-runtime-smoke/references/claude-code.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
scripts/claude-gpt/launch.sh自体の修正が必要と判明した場合(Issue 実装: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2158 / PR feat: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2162 側の scope へ差し戻す)- live claude-gpt launcher 実行による evidence 再取得が必須と判明した場合(対象 Issue 側の運用へ差し戻し、本 Issue は判定ロジック追加のみに留める)
- interactive lane に対して structured lane 相当の hook payload 観測チャネルを新設する必要があると判明した場合(herdr 側の構造的制約変更が必要になり別 Issue の scope になるため)
Required Skills
なし
Required Design References
scripts/agent-ops/run_worktree_agent_runtime_smoke.pydocs/dev/runtime-verification-policy.md- Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174(本 follow-up の起票元、OWNER REQUEST_CHANGES コメント: https://github.com/squne121/loop-protocol/issues/2174#issuecomment-5302215173)
- PR 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加する (#2174) #2176(実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 の実装 PR。marker ベース PASS 判定の現状実装箇所)
- PR 実装: claude-gpt auto mode に canonical AGY/GitHub trust policy と live canary を追加する (#2203) #2214 OWNER レビューコメント(https://github.com/squne121/loop-protocol/pull/2214#issuecomment-5307009937。P0-4 で本 Issue を causal evidence 基盤の pre-merge dependency と位置づけている)
Runtime Verification Applicability
- decision: not_applicable
- reason:
subagent_causal_evidence_verdict()は既存のextract_claude_hook_agent_identity/extract_claude_hook_lifecycle_eventsと同様、既にキャプチャされた stdout テキスト(JSON イベント列)を入力とする純粋関数として実装可能であり、合成 stdout fixture を用いた hermetic pytest で全 AC を決定論的に検証できる。live claude-gpt launcher 実行や実際の Herdr session を新規に起動する必要はない。
applicable_acs: なし
execution_environment: N/A(hermetic pytest のみで検証完結)
skip_conditions: N/A
fallback_policy: N/A
artifact_requirements: N/A
Notes for Reviewer
- dedupe_key:
follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/issues/2174#issuecomment-5302215173:hook-based-causal-evidence-and-policy - overlap preflight(
check_issue_overlap.py)の結果はdecision: ambiguous_requires_human(policy_class: C2b、reason_code: dependency_ambiguous)で、候補 Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 とscripts/agent-ops/run_worktree_agent_runtime_smoke.py等の Allowed Paths が重複する。これは想定通りであり、実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 が OWNER REQUEST_CHANGES(https://github.com/squne121/loop-protocol/issues/2174#issuecomment-5302215173)で本 Issue の scope(hook ID ベース causal evidence 基盤・グローバル runtime verification policy 変更)を明示的に Out of Scope とし、別 Issue へ分離することを求めたための意図的な後続 Issue である(導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 Owner Decision により advisory)。 subagent_causal_evidence_verdict()/causal_evidence_source/tool_invocation_id_correlatedの具体的な関数名・フィールド名は本 Issue の提案であり、実装時に既存コードの命名規約(CHILD_TERMINAL_STATUS_*等)との整合を優先して調整してよい。その場合は Scope Delta として記録する。- 2026-08-16 in-place reframe(本追記): 初版本文は structured/interactive 双方に無条件で
causal_evidence_source == hook_id_correlatedを必要条件として課しており、起点となった Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174 OWNER コメント(interactive lane は operability/multi-turn 証明、Skill/SubAgent 因果性は structured hook evidence で証明、という lane separation の明示的推奨)と不整合だった。PR feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定を追加する #2220 の実装は初版本文どおりに実装すると interactive lane(herdr pane が hook payload を構造的にエコーしない)が恒常 FAIL する構造的制約に直面し、fix_delta で lane separation・structured lane 既定強制/interactive lane opt-in の設計へ収束していた。本追記は、4体の read-only SubAgent 調査(contract/SSOT analyst・causal-evidence adversarial reviewer・runtime/CI verifier・documentation reviewer)の結果に基づき、OWNER intent と PR 実装済み設計の双方に一致するよう In Scope・AC・VC を同期したものである。あわせて、adversarial reviewer が specification gap として指摘した「tool_invocation_id_correlatedが判定に反映されていない」「agent_transcript_pathの実在性・内容相関が未検証」「無関係 SubAgent + parent 生成 marker の negative control が未実装」の3点を AC3/AC11/AC12 として新設した。
Scope Delta(該当時のみ記載)
N/A(本 Issue 自体の in-place reframe。実装時の命名規約調整は引き続き Scope Delta として PR 側に記録する)
Delivery Rule
1 Issue = 1 PR で repository implementation を完結させる。dedicated worktree で作業し、Draft PR をデフォルトとする。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Aug 16, 2026
implement-issue: 実装完了
.claude/worktrees/issue-2183-worktree-agent-runtime-smoke-hook-id-subworktree-issue-2183-worktree-agent-runtime-smoke-hook-id-subdb341004eeb3b230a509a1fe476a105a1aca544ffix: PR #2214 OWNER adversarial review の P0-2/P0-3/P0-6/P1-1〜P1-4 を反映する
fix: SubAgent Causal Evidence 見出しの日本語比率不足を解消する (#2183)
fix: 構造化 lane の SubAgent causal evidence gate を expect-marker 指定時に既定強…
実装: claude-gpt auto mode に canonical AGY/GitHub trust policy と live c…
fix: causal evidence gate に AC3強化/AC11/AC12 を追加し AC13 documentation を…
fix: PR #2220 OWNER REQUEST_CHANGES P0-1〜P1-2 に対応する fix_delta
fix: --require-subagent-causal-evidence を interactive lane で誤って argpa…
feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evi…
Merge main (bring in PR #2220) into worktree-issue-2219-claude-gpt-mu…