Repository navigation
Closed
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: research
parent_issue: "なし(単独改善)"
goal_ref: "Claude Code custom SubAgent(codebase-investigator / web-researcher)の native spawn event 観測を安定化し、spawn_not_observed と validation_failed の failure class を diagnostic_cause taxonomy で lossless に診断可能にする"
change_kind: research-onlyParent Issue
なし(単独改善)
Outcome
PR #2005(Issue #1886)の impl-review-loop iteration 3 で観測された claude_code runtime required route の非決定的 failure(spawn_not_observed / validation_failed)について、Agent tool dispatch → SubagentStart → SubagentStop → tool_result → terminal marker の lifecycle checkpoint 単位での原因切り分け・control lane と production lane を分離した固定試行数での再現性測定・拡張 diagnostic_cause taxonomy による分類が、machine-readable な raw evidence(JSONL)と、そこから再計算可能な human-readable summary の両方で記録された状態。原因が repo 側のコード欠陥と判明した場合は、対応する implementation issue が起票されて link される。
In Scope
- Lifecycle evidence の段階別マッピング:
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyのextract_claude_child_session_id()/extract_claude_parent_session_id()/extract_claude_child_agent_type()(PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 で main にマージ済み、merge commit28394e226533cd59cdfc0f55602ac65e389a6600)が、stdout stream-json のどのイベント種別・どのJSONフィールドから何を算出しているかを、spawn-time evidence(例: 最初の JSON event のsession_id)と completion-time evidence(例:type:"user"のtool_use_result.agentId/agentType)に区別してコードレベルで確定する。特にextract_claude_child_session_id()がparent_session_id欠落時に stdout の child agentId 探索自体をスキップして即Noneを返す挙動(情報を潰す既知の欠陥)を記録する。 - 公式 hook lifecycle event との突き合わせ:
--include-hook-events指定時に stream-json へ混在するSubagentStart/SubagentStophook event(公式スキーマ:agent_id,agent_type,agent_transcript_path,stop_reason,last_assistant_message等)を、現行 harness が実際に parse・比較しているか確認する。リポジトリの.claude/settings.jsonにはSubagentStophook のみが登録されSubagentStarthook は未登録であることを踏まえ、research 用の control lane では session-local--settings上書きでSubagentStart/SubagentStop双方を明示的に構成する。 - failure taxonomy の再構成:
scripts/agent-ops/run_agent_provider_route_smoke.pyの_run_route_once()における失敗判定の実際の評価順序(gemini_invoked→direct_fallback_invoked→ harness exit 77 (agy_unavailable) → harness exit != 0 (validation_failed) →native_spawn_event_observed == False(spawn_not_observed) →request_validation != "pass"(validation_failed) →selected_provider != "agy"(provider_mismatch) →wrapper ok == False(validation_failed))をコードから再構成し、harness non-zero exit が spawn evidence 判定より先に評価されるため「spawn evidence も欠落している validation_failed」が発生しうることを diagnostic_cause taxonomy で分離可能にする。 - 拡張 diagnostic_cause taxonomy: 既存の2値分類(
spawn_not_observed/validation_failed)を維持したまま、research artifact 内では次の diagnostic_cause で原因を lossless に記録する:spawn_not_attempted,subagent_start_not_observed,subagent_completion_timeout,tool_result_identity_not_observed,agent_type_mismatch,runtime_api_retry_timeout,runtime_nonzero,terminal_event_missing,marker_not_observed,request_validation_failed,delegation_wrapper_failed,downstream_route_failed。既存 schema(spawn_not_observed/validation_failed)自体は本 Issue では変更しない。 - control lane と production lane の分離:
_is_transient_infrastructure_candidate()が現状codex_cli+spawn_not_observedのみを bounded single retry 対象とし、claude_code+spawn_not_observedを明示的に対象外としている設計(既存テストtest_claude_spawn_not_observed_is_not_transient_candidateで固定)が、observed non-determinism の実態と整合するかを、AGY/Serena/GitHub 等の downstream failure(実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012, 実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する #2015 相当)を混入させない形で評価する。- control lane: Claude Code CLI の
--agents(dynamic custom subagent 定義の inline JSON 指定)を用い、外部 provider / Serena / GitHub retrieval を一切必要としない最小 custom agent を spawn する。research artifact directory 内に一時 session-local--settingsファイルを作成し、SubagentStart/SubagentStophook 双方を no-op logger として構成して lifecycle event を観測する。repo-tracked.claude/settings.jsonや.claude/hooks/**は変更しない。 - production lane: 現行 main の実
codebase-investigator(local_asset_research経由で Serena MCP に到達)/web-researcher(AGY grounded research 経由)を対象にする。spawn lifecycle evidence と、その後の AGY/Serena/GitHub route outcome を別カラムとして保存し、実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012/実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する #2015 相当の downstream failure を spawn failure に再分類しない。
- control lane: Claude Code CLI の
- 固定試行数での再現性測定: control lane・production lane それぞれ 15 回(固定) を実行する(真の失敗率が20%ある場合に少なくとも1回観測できる確率は約96.5%という統計的下限に基づく)。各 trial について Claude Code version、tested git SHA、prompt SHA256、agent-definition SHA256、effective settings/config digest、timeout、max-turns、開始/終了時刻、上記 lifecycle checkpoint 12項目の presence flag、
system/api_retrycount を記録する。trial を途中で追加・除外した場合は理由を ledger に残し cherry-pick しない。
Out of Scope
- 「観測できなかったので expected agent_type を代入する」「self-report を identity evidence にする」等、証拠の水準を下げる変更(禁止)。
- 何度も再実行して一度通った run だけを採用する運用(禁止)。
- provider routing 自体(AGY/Gemini 選択ロジック)の変更。
- Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886(PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005)の Allowed Paths 拡張、および同 PR への直接コミット。
- silent retry、2回以上の追加 retry、成功するまでの反復 retry の実装(禁止)。
scripts/agent-ops/run_worktree_agent_runtime_smoke.py/scripts/agent-ops/run_agent_provider_route_smoke.py自体のコード変更(原因が repo 側のコード欠陥と判明した場合は、対応する implementation issue を別途起票して実施する)。- codex_cli runtime の
spawn_not_observedtransient retry 対象化ロジック自体の変更(既存契約は維持する)。 run_refinement_preflight.pyのrepair_diagnosticsblocker が confidence を無視して常時 human_judgment_required を発火する control-plane wiring gap の修正(既存 OPEN Issue 実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 で追跡済み。本 Issue はこれを吸収しない)。- repo-tracked
.claude/settings.json/.claude/hooks/**の変更(control lane は session-local--settings上書きのみで実現する)。 SubagentStart/SubagentStophook 自体を identity evidence の唯一の正本に置き換える設計変更(upstream #27755 の既知 reliability 問題があるため、hook と tool-result の複数チャネルを突き合わせる設計を維持する。#27755 は community bug report であり公式契約ではないことを research artifact 内で明記する)。
Acceptance Criteria
- AC1:
code-analysis.mdに、(a)extract_claude_child_session_id()/extract_claude_parent_session_id()/extract_claude_child_agent_type()の spawn-time evidence / completion-time evidence 区分、(b)_run_route_once()の failure 判定の実際の評価順序(ファイルパス:行番号付き)、(c) 拡張 diagnostic_cause taxonomy の定義、の3点が記録されており、tests/test_code_analysis_contract.py(pytest)がこの3点の記録を機械検証する。 - AC2:
reproduction-log.jsonlに、control lane 15 trial・production lane 15 trial(計30 trial 以上)の raw record が1行1 JSON object で記録されており、各 record がtrial_id/lane/route/claude_code_version/tested_head_sha/prompt_sha256/agent_definition_sha256/effective_settings_digest/timeout_seconds/max_turns/start_time/end_time/lifecycle(12 checkpoint の boolean)/failure_class/diagnostic_causeを持つことをtests/test_reproduction_log_contract.py(pytest)が機械検証する。 - AC3:
reproduction-log.mdに、AC2 のreproduction-log.jsonlから再計算可能な lane 別・diagnostic_cause 別の分布サマリが記録されていることをtests/test_reproduction_summary_contract.py(pytest)が機械検証する。 - AC4:
retry-policy-assessment.mdに、_is_transient_infrastructure_candidate()の現行設計(claude_code+spawn_not_observedを transient 対象外とする判断)が AC2 の観測データと整合するかどうかの評価結果が記録されていることをtests/test_retry_policy_assessment_contract.py(pytest)が機械検証する。 - AC5:
conclusion.mdに、結論カテゴリ(repo_observability_defect/upstream_runtime_contract_or_bug/transient_infrastructure/model_orchestration_nonspawn/downstream_route_failure/inconclusiveのいずれか)、bounded single retry 適用可否、追加 failure class 細分化の要否、follow-up implementation issue の起票有無が、AC2 の raw observation から再計算可能な形で記録されていることをtests/test_conclusion_contract.py(pytest)が機械検証する。
Verification Commands
# AC1
# baseline-expect: fail
$ uv run pytest artifacts/claude-code-spawn-observability-research/tests/test_code_analysis_contract.py# AC2
# baseline-expect: fail
$ uv run pytest artifacts/claude-code-spawn-observability-research/tests/test_reproduction_log_contract.py# AC3
# baseline-expect: fail
$ uv run pytest artifacts/claude-code-spawn-observability-research/tests/test_reproduction_summary_contract.py# AC4
# baseline-expect: fail
$ uv run pytest artifacts/claude-code-spawn-observability-research/tests/test_retry_policy_assessment_contract.py# AC5
# baseline-expect: fail
$ uv run pytest artifacts/claude-code-spawn-observability-research/tests/test_conclusion_contract.pyAllowed Paths
- artifacts/claude-code-spawn-observability-research/
Stop Conditions
- Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
- Allowed Paths 外への書き込みを試みた場合は即停止
- 権限不足(permission denied)により操作が完了できない場合は即停止
- 成果物の書き込みに失敗した場合(I/O エラー等)は即停止
- repo-tracked
.claude/settings.json/.claude/hooks/**の変更を試みた場合は即停止
Handoff Contract
Current ObjectiveBounded Current ContextOpen QuestionsNext ActionArtifact Refs
Notes for Reviewer
- 起票元: impl-review-loop for 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 / PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 の OWNER human-escalation resolution(AC6 未達を「PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 の既知コード欠陥」ではなく「acceptance を完了するための runtime prerequisite / reliability gap」として分離する決定)。
- PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 は merge commit
28394e226533cd59cdfc0f55602ac65e389a6600で main に merge 済み(現在の origin/main HEAD と一致、2026-08-08 時点で追加コミットなし)。extract_claude_child_session_id()等は現在 main で利用可能。research 実行時に origin/main がさらに進んでいる場合は、historical baseline SHA(28394e226533cd59cdfc0f55602ac65e389a6600)と current observed main SHA の両方を記録し、どちらを trial 対象にしたか明示すること。 _run_route_once()の失敗判定順序(判定順、control-plane 独立検証済み、2026-08-08): (1) gemini invocation hit →gemini_invoked、(2) fallback invocation hit →direct_fallback_invoked、(3) harness exit 77 →agy_unavailable、(4) harness exit != 0 →validation_failed、(5)native_spawn_event_observed == False→spawn_not_observed、(6)request_validation != "pass"→validation_failed、(7)selected_provider != "agy"→provider_mismatch、(8)wrapper ok == False→validation_failed。(4)が(5)より先に評価されるため、spawn evidence も欠落したvalidation_failedが発生しうる。extract_claude_child_session_id()はparent_session_idが欠落していると、stdout に childagentIdが存在しても検索せず即Noneを返す(run_worktree_agent_runtime_smoke.py内、control-plane 独立検証済み)。.claude/settings.jsonの lifecycle hook は現状SubagentStopのみでSubagentStarthook は未登録(control-plane 独立検証済み)。- Claude Code 公式ドキュメント(2026-08-08 時点、web-researcher 経由で独立検証済み):
SubagentStart/SubagentStophook のペイロードスキーマ(agent_id/agent_type/agent_transcript_path/stop_reason/last_assistant_message等)、--include-hook-events/--settings/--agents/--no-session-persistence/--max-turnsの各 CLI フラグ、system/api_retrystream-json イベントは https://code.claude.com/docs/en/hooks 、https://code.claude.com/docs/en/cli-usage 、https://code.claude.com/docs/en/headless に明記された公式契約。一方tool_use_result.agentId/agentTypeは SDK example code に言及があるのみで公式型スキーマは未確認(undocumented / observational)。GitHub upstream Issue [BUG] SubagentStart/SubagentStop unreliable for settings.json hooks — cascade failures break agent lifecycle management anthropics/claude-code#27755 はSubagentStart/SubagentStophook の信頼性問題(一部シナリオで42-70%の未発火)を報告するコミュニティ報告であり、"Closed as not planned"。公式契約としては扱わず、hook を identity evidence の唯一の正本にしない設計判断の補助資料として扱う。 _is_transient_infrastructure_candidate()は既存テスト(scripts/agent-ops/tests/test_agent_provider_route_smoke.py)でcodex_cli+spawn_not_observedのみを transient candidate とし、claude_code+spawn_not_observedは明示的に non-transient としてテストされている(test_claude_spawn_not_observed_is_not_transient_candidate)。この既存契約を変更する場合は、対応する implementation issue で test 契約ごと改訂すること。- 関連: 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886(本 Issue のスコープ分離元)、実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842(Claude Code / Codex CLI nested delegation canary。スコープは異なる: implementation-worker からの nested delegation canary であり、本 Issue は custom SubAgent 単体 spawn の観測安定化)、実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012(GH_TOKEN provisioning、downstream failure として分離)、実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する #2015(Serena MCP timeout、downstream failure として分離)、実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016(
repair_diagnosticsblocker の confidence-aware 化。issue-refinement-loop control-plane の wiring gap であり本 Issue のスコープには含めない)。 - anchor comment(OWNER, REQUEST_CHANGES, https://github.com/squne121/loop-protocol/issues/2013#issuecomment-5223647017)の P0-1〜P0-6/P1-1〜P1-3 は、issue-refinement-loop の Investigation(codebase-investigator/web-researcher、2026-08-08 実施)で独立検証され、全項目 confirmed と判定された(P0-6 の false-green は AC1〜AC5 の再設計と
# baseline-expect: fail注釈で対処、P1-1 の stale ref は PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 merge により解消)。
Metadata
Metadata
Assignees
Labels
No labels
Activity
squne121 commentedon Aug 8, 2026
判定: REQUEST_CHANGES
Issue #2013 の方向性自体は妥当です。#1886 の OWNER 判断でも、PR #2005 のコード欠陥とは断定できなかった runtime prerequisite / reliability gap の一つとして #2013 が明示的に分離されています。
ただし、現状の Issue 契約のまま調査を開始すると、
優先度 | 指摘 | 問題 -- | -- | -- P0-1 | validation_failed の定義が実装と一致しない | Issue 冒頭では「native spawn は観測済みだが marker timeout」と定義していますが、実装では harness non-zero、request validation failure、wrapper failure も全部 validation_failed です。しかも harness non-zero 判定が native_spawn_event_observed 判定より先なので、「spawn evidence も欠落している validation_failed」も発生します。 P0-2 | 現行 Claude evidence は「spawn event」ではなく実質 Agent tool completion evidence | extractor は type:user の tool_use_result.agentId/agentType を読んでいます。コード自身もこれを「実観測した undocumented API」と記述しています。Agent が起動済みでも子 Agent が timeout 前に返らなければ、この evidence は出ません。一方 Claude Code 公式には SubagentStart が spawn 時に発火し agent_id / agent_type を持つ契約があります。 (Claude) P0-3 | 公式の別観測チャネルを無視している | harness は既に --include-hook-events を付けています。公式 CLI も hook lifecycle event を stream-json に含める機能を明示しています。さらにリポジトリの .claude/settings.json には全 SubAgent 向け SubagentStop hook が既にあります。現状 extractor はこれを identity evidence として一切比較していません。 (Claude) P0-4 | spawn 調査に downstream AGY failure が混入する | local_asset_research には既知の Serena MCP timeout #2015、github_research には GH_TOKEN provisioning #2012 があります。production route の反復だけでは「Claude spawn の非決定性」と「spawn 後の AGY/Serena/GitHub failure」を分離できません。 P0-5 | native_spawn_event_observed が情報を潰しすぎる | 最終 boolean は parent ID、child ID、ID 相違、agent-type identity の4条件をANDしています。さらに extract_claude_child_session_id() は parent ID が無いと、stdout に child agentId が存在しても検索せず即 None です。何が欠けたのかを boolean から復元できません。 P0-6 | AC が空ファイルでも PASS する | AC1〜AC4 の Verification Commands はすべて test -f だけです。空の Markdown を4枚置けば Issue contract 上完了できます。調査 Issue としては decisive false-green です。 P1-1 | 調査対象 ref が既に stale | #2013 は「extractor は PR #2005 branch のみ」と記載していますが、#2013 起票の約7分後に PR #2005 は merge commit 28394e2... として main に入り、現在 PR は merged: true です。調査対象を branch ではなく exact main SHA に固定すべきです。 P1-2 | 「複数回」が実験条件として弱い | runtime version、tested head、prompt hash、timeout、max turns、agent definition SHA、試行数を固定しないと分布比較が成立しません。Claude Code は SubAgent/hook 周辺が継続的に変更されており、公式 changelog にも agent ID / hook 関連変更が続いています。 (GitHub) P1-3 | 結論の三分類が不足 | 「repo defect / transient infra / 判別不能」だけでは、upstream Claude Code contract drift、model が Agent を呼ばなかった、spawn 済みだが child completion timeout、downstream AGY failure を表現できません。retry 判断には別分類が必要です。spawn_not_observedの原因診断と retry 可否判定を誤る可能性があります。特に Claude Code の「spawn」と「Agent 完了結果」の観測が混同されています。最も重要な技術的修正
#2013 は 「failure class の回数を数える調査」から「SubAgent lifecycle の各段階を別々に観測する調査」へ変更すべきです。
Claude Code 公式では
SubagentStartにagent_idとagent_typeがあり、SubagentStopにも同じ identity とagent_transcript_pathがあります。CLI は--include-hook-eventsをサポートし、--settingsでセッション限定の設定を上書きできます。(Claude) したがって research run では少なくとも次の lifecycle を独立記録するのが適切です。これで例えば、
なら spawn_not_observed ではなく child completion timeout です。
逆に、
なら、子 Agent は確実に実行完了しているため、retry で隠すべき transient infra ではなく current extractor / Claude stream surface の observability gap が第一候補になります。
なお、hook を唯一の正本に置き換えるのも早計です。Anthropic の公式リポジトリには 2026 年2月に SubagentStart/SubagentStop の不整合を訴えるユーザー報告もあります。これは仕様そのものではありませんが、hook と tool-result の2チャネルを突き合わせる研究設計にすべき理由になります。(GitHub)
timeout も
validation_failedから分離すべきClaude Code は retryable API error 時に
system/api_retryを stream-json へ出すことが公式仕様です。(Claude) また Agent SDK の現行仕様では、CLI subprocess の API timeout 既定値は 600 秒、API retry 既定上限は10回です。(Claude)一方 route smoke のデフォルトは180秒です。したがって、
と
を同じ
validation_failedにしてはいけません。少なくとも research artifact 内では、
程度へ原因軸を分解することを推奨します。既存 schema を研究 Issue 内で変更する必要はなく、research-only の
diagnostic_causeとして記録すれば十分です。AC2 には control lane が必要
production route だけを繰り返す設計は避けるべきです。
codebase-investigatorはlocal_asset_researchを経由し、その先に Serena MCP が存在します。現在の agent definition 自体もmodel: haikuで AGY delegation を要求しています。 web-researcher も同様に Haiku + AGY grounded research です。したがって AC2 は「spawn-only control」と「production route」を並走させるべきです。前者は custom
codebase-investigatorを起動するが downstream AGY 処理を最小化・早期終了できる入力、後者は既存 route smoke とします。control が20/20安定し production だけ落ちるなら、「Claude spawn non-determinism」という仮説自体がかなり弱くなります。試行数も「複数」ではなく固定してください。例えば 各条件15回なら、真の失敗率が20%ある場合に少なくとも1回観測できる確率は約96.5%です。これは厳密な reliability certification ではありませんが、今回の診断用途には妥当な下限です。
修正後の AC の最小形
AC1 は単なる extractor 読解ではなく、
Agent tool_use → SubagentStart → SubagentStop → tool_result → marker → delegation resultの段階別 failure matrix を必須にする。AC2 は exacttested_head、Claude Code version、prompt SHA、agent-definition SHA、timeout/max-turns、試行数、上記 lifecycle の各 presence flag、system/api_retrycount を記録する。AC3 は 「retry したら通った」だけを transient の根拠として禁止し、どの diagnostic cause のみ retryable とするかを決める。AC4 の結論カテゴリにはrepo_observability_defect / upstream_runtime_contract_or_bug / transient_infrastructure / model_orchestration_nonspawn / downstream_route_failure / inconclusiveを含めるべきです。成果物も Markdown だけでなく、例えば
reproduction-log.jsonlを正本として Markdown を集計ビューにすると後続 implementation issue でそのまま fixture 化できます。Verification Commands はtest -fではなく、required keys・試行数・全 run の同一 head/runtime 条件を機械検証する必要があります。最後に運用上の小さい罠があります。
run_agent_provider_route_smoke.pyは--output-dir未指定時.claude/artifacts/agent-provider-route/...に書く一方、#2013 の Allowed Paths はartifacts/claude-code-spawn-observability-research/のみです。 AC2 の実行コマンドには必ず研究ディレクトリ配下の--output-dirを明記してください。そうしないと Issue 自身の Stop Condition と live reproduction が衝突します。結論として、research Issue として残すことには賛成ですが、現状の契約では着手非推奨です。特に P0-1〜P0-6 を直した後なら、「Claude は in-memory stdout だから miss は絶対 non-transient」という現在の仮説を、公式の Subagent lifecycle telemetry と実測で正しく検証できる Issue になります。
## 判定: **REQUEST_CHANGES**Issue #2013 の方向性自体は妥当です。#1886 の OWNER 判断でも、PR #2005 のコード欠陥とは断定できなかった runtime prerequisite / reliability gap の一つとして #2013 が明示的に分離されています。
ただし、現状の Issue 契約のまま調査を開始すると、
spawn_not_observedの原因診断と retry 可否判定を誤る可能性があります。特に Claude Code の「spawn」と「Agent 完了結果」の観測が混同されています。validation_failedの定義が実装と一致しないvalidation_failedです。しかも harness non-zero 判定がnative_spawn_event_observed判定より先なので、「spawn evidence も欠落している validation_failed」も発生します。type:userのtool_use_result.agentId/agentTypeを読んでいます。コード自身もこれを「実観測した undocumented API」と記述しています。Agent が起動済みでも子 Agent が timeout 前に返らなければ、この evidence は出ません。一方 Claude Code 公式には SubagentStart が spawn 時に発火しagent_id/agent_typeを持つ契約があります。 ([Claude]1)--include-hook-eventsを付けています。公式 CLI も hook lifecycle event を stream-json に含める機能を明示しています。さらにリポジトリの.claude/settings.jsonには全 SubAgent 向けSubagentStophook が既にあります。現状 extractor はこれを identity evidence として一切比較していません。 (Claude)local_asset_researchには既知の Serena MCP timeout #2015、github_researchには GH_TOKEN provisioning #2012 があります。production route の反復だけでは「Claude spawn の非決定性」と「spawn 後の AGY/Serena/GitHub failure」を分離できません。native_spawn_event_observedが情報を潰しすぎるextract_claude_child_session_id()は parent ID が無いと、stdout に childagentIdが存在しても検索せず即Noneです。何が欠けたのかを boolean から復元できません。test -fだけです。空の Markdown を4枚置けば Issue contract 上完了できます。調査 Issue としては decisive false-green です。28394e226533...として main に入り、現在 PR はmerged: trueです。調査対象を branch ではなく exact main SHA に固定すべきです。upstream Claude Code contract drift、model が Agent を呼ばなかった、spawn 済みだが child completion timeout、downstream AGY failureを表現できません。retry 判断には別分類が必要です。最も重要な技術的修正
#2013 は 「failure class の回数を数える調査」から「SubAgent lifecycle の各段階を別々に観測する調査」へ変更すべきです。
Claude Code 公式では
SubagentStartにagent_idとagent_typeがあり、SubagentStopにも同じ identity とagent_transcript_pathがあります。CLI は--include-hook-eventsをサポートし、--settingsでセッション限定の設定を上書きできます。(Claude) したがって research run では少なくとも次の lifecycle を独立記録するのが適切です。これで例えば、
なら spawn_not_observed ではなく child completion timeout です。
逆に、
なら、子 Agent は確実に実行完了しているため、retry で隠すべき transient infra ではなく current extractor / Claude stream surface の observability gap が第一候補になります。
なお、hook を唯一の正本に置き換えるのも早計です。Anthropic の公式リポジトリには 2026 年2月に SubagentStart/SubagentStop の不整合を訴えるユーザー報告もあります。これは仕様そのものではありませんが、hook と tool-result の2チャネルを突き合わせる研究設計にすべき理由になります。([GitHub]4)
timeout も
validation_failedから分離すべきClaude Code は retryable API error 時に
system/api_retryを stream-json へ出すことが公式仕様です。([Claude]5) また Agent SDK の現行仕様では、CLI subprocess の API timeout 既定値は 600 秒、API retry 既定上限は10回です。([Claude]6)一方 route smoke のデフォルトは180秒です。したがって、
と
を同じ
validation_failedにしてはいけません。少なくとも research artifact 内では、
程度へ原因軸を分解することを推奨します。既存 schema を研究 Issue 内で変更する必要はなく、research-only の
diagnostic_causeとして記録すれば十分です。AC2 には control lane が必要
production route だけを繰り返す設計は避けるべきです。
codebase-investigatorはlocal_asset_researchを経由し、その先に Serena MCP が存在します。現在の agent definition 自体もmodel: haikuで AGY delegation を要求しています。 web-researcher も同様に Haiku + AGY grounded research です。したがって AC2 は「spawn-only control」と「production route」を並走させるべきです。前者は custom
codebase-investigatorを起動するが downstream AGY 処理を最小化・早期終了できる入力、後者は既存 route smoke とします。control が20/20安定し production だけ落ちるなら、「Claude spawn non-determinism」という仮説自体がかなり弱くなります。試行数も「複数」ではなく固定してください。例えば 各条件15回なら、真の失敗率が20%ある場合に少なくとも1回観測できる確率は約96.5%です。これは厳密な reliability certification ではありませんが、今回の診断用途には妥当な下限です。
修正後の AC の最小形
AC1 は単なる extractor 読解ではなく、
Agent tool_use → SubagentStart → SubagentStop → tool_result → marker → delegation resultの段階別 failure matrix を必須にする。AC2 は exacttested_head、Claude Code version、prompt SHA、agent-definition SHA、timeout/max-turns、試行数、上記 lifecycle の各 presence flag、system/api_retrycount を記録する。AC3 は 「retry したら通った」だけを transient の根拠として禁止し、どの diagnostic cause のみ retryable とするかを決める。AC4 の結論カテゴリにはrepo_observability_defect / upstream_runtime_contract_or_bug / transient_infrastructure / model_orchestration_nonspawn / downstream_route_failure / inconclusiveを含めるべきです。成果物も Markdown だけでなく、例えば
reproduction-log.jsonlを正本として Markdown を集計ビューにすると後続 implementation issue でそのまま fixture 化できます。Verification Commands はtest -fではなく、required keys・試行数・全 run の同一 head/runtime 条件を機械検証する必要があります。最後に運用上の小さい罠があります。
run_agent_provider_route_smoke.pyは--output-dir未指定時.claude/artifacts/agent-provider-route/...に書く一方、#2013 の Allowed Paths はartifacts/claude-code-spawn-observability-research/のみです。 AC2 の実行コマンドには必ず研究ディレクトリ配下の--output-dirを明記してください。そうしないと Issue 自身の Stop Condition と live reproduction が衝突します。結論として、research Issue として残すことには賛成ですが、現状の契約では着手非推奨です。特に P0-1〜P0-6 を直した後なら、「Claude は in-memory stdout だから miss は絶対 non-transient」という現在の仮説を、公式の Subagent lifecycle telemetry と実測で正しく検証できる Issue になります。
squne121 commentedon Aug 8, 2026
issue-refinement-loop 終了報告(human_judgment_required)
対象 anchor comment: #2013 (comment)
STATUS
blocked/NEXT_ACTION: human_judgment_required(preflight 段階で停止、review/rewrite ループ未開始)停止理由
repair_issue_contract(dry-run)が現行 Issue 本文の Verification Commands 4箇所(AC1〜AC4 に対応するtest -f artifacts/claude-code-spawn-observability-research/{code-analysis.md,reproduction-log.md,retry-policy-assessment.md,conclusion.md})にbaseline-expect注釈欠落を検出しました。これは anchor comment の内容とは独立に、常時 fail-closed で発火する preflight 前段の構造ゲートです。# baseline-expect: failを挿入する提案(dry-run のみ、body 未変更).claude/artifacts/issue-refinement-loop/2013/repair_diagnostics.jsonno_scope_signalの機械的 trusted directive ではなく、Issue 契約自体の実質的な作り直しを要求する内容(P0-1〜P0-6 / P1-1〜P1-3:validation_failed定義の実装不一致、spawn event と Agent completion evidence の混同、AC が空ファイルで PASS してしまう false-green、AC 自体を lifecycle-based failure matrix に再設計する提案 等)でした。そのためcontract_update.run.with_anchorの "trusted directive noop patch" consume モードは対象外と判定され(設計通り)、通常の Investigation → Review → Rewrite ループでの本文書き換えが必要な内容です。次のアクション(人間判断が必要な理由)
repair_diagnosticsの baseline-expect 挿入提案を採用するか、AC自体を anchor comment の指摘に沿って作り直す過程で VC を全面的に書き換えるか、方針決定が必要です。issue-refinement-loopを再実行すれば Step 1(investigation)以降のループへ進めます。参考
.claude/artifacts/issue-refinement-loop/2013/raw_issue_snapshot.jsonのanchor_comment.snapshotを参照してください。squne121 commentedon Aug 8, 2026
前回の Claude Code の停止判断は、現行 SKILL への逐語的準拠としては正しいが、根本原因の診断と次のルーティングとしては
REQUEST_CHANGESです。敵対的レビュー
1. 「人間承認不要なのに止まった」こと自体は Claude の規約違反ではありません。
issue-refinement-loopのloop_iteration_approval_gate.default_required: falseは、needs-fix 後の反復承認を省略するだけです。preflight がSTATUS: blocked/environment_failureを返した場合は別契約で、SKILL は明示的に停止を要求しています。ただし、今回
blockedを作っている仕組み自体に contract dead-end があるのが重要です。repair_issue_contractが変更可能な修復を見つけると、preflight はrepair_diagnosticsを generic blocker に追加し、generic blocker はblockedに変換されます。2. これは #899 / PR #952 の設計意図と正面から衝突しています。 PR #952 はまさに「新規 Allowed Path の
baseline-expect欠落をneeds_fix/ body-author-fixable とし、不要な human escalation を防ぐ」ための変更で、# baseline-expect: failの deterministic insert まで実装しています。したがって前回 Claude の
という説明は、現在のコードの挙動説明としては正しい一方、リポジトリの設計履歴まで含めれば不十分です。より正確には「#899 で deterministic repair lane に流す意図だったものが、現在の preflight wiring では generic blocker に再変換されている」です。
さらに、前回が提示した「① baseline 注釈を入れる / ② anchor に従って全面書換え」は本来二者択一ではありません。①を機械的 hygiene repair として先に適用し preflight を通し、その後②を semantic refinement として行うのが自然です。
3. anchor comment の技術レビューはほぼ正しいです。 現在の Claude lane は
--include-hook-eventsを既に付けていますが、SubagentStartを解析していません。その代わりtool_use_result.agentId/agentTypeを child identity として取り出しています。つまりnative_spawn_event_observedという名前に対し、Claude 側の実体はかなり completion-side の証拠です。Claude Code の現行公式仕様では
SubagentStartは subagent spawn 時に発火しagent_id/agent_typeを持ち、SubagentStopは応答終了時の別イベントです。また--include-hook-eventsはこれら hook lifecycle events を stream-json に含めるための正式な CLI surface です。([Claude]1)一方、この repository の
.claude/settings.jsonにある lifecycle hook は現状SubagentStopだけで、SubagentStarthook は登録されていません。 したがって #2013 では「--include-hook-eventsがあるから Start が必ず取れる」と決め打ちせず、Start hook を明示的に構成した control lane と production lane を分けるべきです。CLI は一時--settingsファイルと--agentsによる動的 custom agent 定義を公式にサポートしているため、repo source を変更せず isolation control を作れます。([Claude]2)なお upstream には
SubagentStart/SubagentStopの不安定性を報告した Issue #27755 もありますが、これは ユーザー報告で、現在は stale / not planned として閉じられているため、製品契約として引用してはいけません。むしろ「公式契約と実測が一致するか #2013 で測る理由」の補助資料に留めるべきです。([GitHub]3)4.
validation_failedの問題も実コードで再現します。harness_exit != 0がnative_spawn_event_observedより先に判定されてvalidation_failedになるため、anchor の「validation_failed なのに spawn evidence 自体も無いケースがあり得る」という指摘は正しいです。 また現在 bounded retry が許可されているのは Codex CLI のspawn_not_observedだけで、Claude lane は明示的に retry 対象外です。5. #2013 は downstream reliability と切断すべきです。
github_researchの GH_TOKEN provisioning は #2012、local_asset_researchの Serena MCP timeout は #2015 に既に分離されています。 このため研究では、最小 custom agent の control lane と実codebase-investigator/web-researcherの production lane を別々に測るのが妥当です。次に渡す実行プロンプト
下記は、前回の
human_judgment_requiredに対する人間判断そのものをプロンプト内で明示し、同じ場所で再停止するのを防ぐ形にしています。Claude Code / Codex CLI のどちらの main session にも渡せます。Issue #2013 の issue-refinement-loop を再開してください。
対象:
28394e226533cd59cdfc0f55602ac65e389a6600今回の human judgment
このプロンプトの実行を、前回
repair_diagnostics -> human_judgment_requiredに対する明示的な人間判断として扱う。前回 repair artifact が Issue #2013 の AC1〜AC4 Verification Commands について提案した、
新規 Allowed Path の baseline 不在ファイルを test -f する VC の直前へ # baseline-expect: fail を挿入するという deterministic hygiene repair は承認する。
ただしこれは Issue #2013 の semantic contract を承認する判断ではない。
live Issue body を再取得し、現在も同じ4件が
missing_baseline_expect_for_new_allowed_pathとして high-confidence / deterministic repair 可能であることを確認した場合に限り適用すること。
body が既に変更されている場合は古い patch を盲目的に適用せず、current body / updatedAt / body SHA に対して repair diagnostics を再生成する。
既存 Issue mutation は raw
gh issue editではなく、repository の canonical controlled mutation laneである.claude/skills/edit-issue/scripts/edit_issue_txn.pyおよび
issue-editor/edit-issuecontract に従って optimistic precondition/readback 付きで行うこと。この hygiene repair 完了後、同じ anchor comment を固定したまま preflight を fresh に再実行し、通常の Investigation → Review → Rewrite → Review loop へ進むこと。
loop_iteration_approval_gate.default_required: falseとして max 3 iterations まで自律継続する。各 iteration の継続確認を人間へ求めない。
最初に行う repository-ops review
作業開始時に current main を fetch/readback し、少なくとも以下を確認する。
AGENTS.mdCLAUDE.md.claude/rules/**の関連規約.claude/settings.json.claude/hooks/**の SubAgent lifecycle 関連.claude/agents/issue-reviewer.md.claude/agents/issue-editor.md.claude/agents/issue-creator.md.claude/agents/codebase-investigator.md.claude/agents/web-researcher.md.codex/agents/**の対応 surface.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-contract-review/**.claude/skills/edit-issue/**scripts/agent-ops/run_worktree_agent_runtime_smoke.pyscripts/agent-ops/run_agent_provider_route_smoke.pyscripts/agent-ops/validate_agent_provider_route_smoke.py可能なら最初に以下の canonical inventory を使用し、その MUST_READ / inventory profile を source of truth とする。
uv run python3 scripts/agent_ops_inventory.py --task-kind issue-refinement-ops-review関連 Issue / PR / comments として最低限以下を読む。
関連関係は current GitHub state で再確認し、古い本文だけを信用しない。
前回停止理由の再評価
前回 agent は
repair_issue_contract changed=True -> repair_diagnostics blocker -> STATUS: blockedを理由に停止した。
現在の
run_refinement_preflight.pyが deterministic repair を generic blocker 化していることと、#899 / PR #952 が missing/inline baseline-expect を body-author-fixable
needs_fixとして扱い不要な human escalation を防ぐ目的で導入されたことの整合性を調べる。これは Issue #2013 の source change scopeには含めない。
control-plane regression / wiring gap が実在すると判断した場合:
今回の explicit human judgment で deterministic baseline repair が正常に適用できたなら、それを理由に再度同じ human_judgment_required で停止しない。
一方、別種類の fail-closed blocker が fresh preflight で出た場合は、内容を捏造して bypass しない。
anchor comment を semantic refinement の authoritative feedback として処理する
baseline annotation repair は anchor comment の REQUEST_CHANGES を解決したことにはしない。
anchor の P0-1〜P0-6 / P1-1〜P1-3 を Investigation / Review / Rewrite で個別に検証し、妥当なものを Issue contract に反映する。
特に以下を独立検証する。
lifecycle evidence
Claude Code の current version と current official documentation を WEB 検索し、少なくとも以下の current semantics を一次情報で確認する。
SubagentStartSubagentStopagent_idagent_type--include-hook-events--settings--agents)--no-session-persistence--max-turns公式仕様と GitHub upstream bug report / community observation は証拠レベルを分離する。
GitHub Issue の報告を公式契約として扱わない。
current harness が実際にどの event / JSON field から
parent_session_id,child_session_id,child_agent_type_observed,agent_type_identity_verified,native_spawn_event_observedを算出しているか、producer→consumer をコードで追う。
特に
tool_use_result.agentId/agentTypeが spawn-time evidence なのか completion-time evidence なのかを区別する。--include-hook-eventsが既に指定されている場合でも、実際に
SubagentStartevent を parser が consume しているかを確認する。failure taxonomy
validation_failed/spawn_not_observedの現在の if/elif evaluation order をコードから再構成する。最終 boolean だけでなく、少なくとも次の lifecycle checkpoints を独立フィールドとして研究対象にする。
spawn 前、spawn 済み、completion 待ち、wrapper failure、downstream route failure を一つの
validation_failedに畳み込まない。研究用
diagnostic_causetaxonomy を定義し、少なくとも anchor comment が要求した原因クラスを lossless に表現する。retryable/non-retryable は観測結果から後段で決め、最初から
spawn_not_observed = transientと仮定しない。control lane と production lane
AGY / Serena / GitHub credential failure を Claude custom SubAgent spawn observability と混同しない。
少なくとも2種類の lane を設計する。
control lane
Claude Code が提供する dynamic custom subagent surface 等を使い、
外部 provider / Serena / GitHub retrieval を一切必要としない最小 custom agent を spawn する。
必要なら artifact directory 内に一時 settings JSON / no-op hook logger を作り、
CLI の session-local settings override で
SubagentStart/SubagentStopを観測する。repo-tracked
.claude/settings.jsonや hooks は変更しない。一時設定を使った場合は production config と同一だと主張せず、
「runtime lifecycle の control experiment」と明示する。
production lane
current main の実
codebase-investigator/web-researcherを対象にする。spawn lifecycle evidence と、その後の AGY / Serena / GitHub route outcome を別カラムとして保存する。
#2012 や #2015 に該当する downstream failure は
spawn failureに再分類しない。repeated trials
「複数回」ではなく trial count を Issue contract に固定する。
最低でも control / production の各 lane について明示的な N を設定し、
Claude Code version、tested git SHA、prompt SHA256、agent definition SHA256、
effective settings/config digest、timeout、max-turns、開始/終了時刻を各 trial に記録する。
trial を途中で追加・除外した場合は理由を ledger に残し cherry-pick しない。
raw evidence は JSONL または equivalent machine-readable format を canonical とし、
Markdown はそこから生成した human-readable summary とする。
source ref
PR #2005 branch を research target と書かない。
少なくとも historical baseline として merge commit
28394e226533cd59cdfc0f55602ac65e389a6600を固定する。
実行時の
origin/mainがさらに進んでいる場合は、を両方記録し、どちらを trial 対象にしたか明示する。
silent に別 SHA へ置換しない。
Acceptance Criteria / Verification Commands
現在の
test -fだけの VC は decisive false-green なので全面的に作り直す。空ファイル4枚で全AC PASSできないことを要求する。
AC は少なくとも次を機械検証できる形にする。
Verification Commands は単なる presence check ではなく、
artifact schema/validator または deterministic structural assertions を実行する。
新規 artifact file を baseline で検査する VC には正しい
# baseline-expect: failを付ける。scope
Issue #2013 は research issue のまま維持する。
原則として repo product/runtime source code を変更する Issue に変えない。
研究成果物は
artifacts/claude-code-spawn-observability-research/配下へ閉じる。
研究によって source change が必要と判明したら、
#2013 自身の Allowed Paths を安易に拡張せず follow-up implementation Issue に分離する。
#2012 / #2015 の既存 owner scope を吸収しない。
refinement loop
deterministic baseline hygiene repair
→ fresh anchored preflight
→ Investigation
→ Review
→ Rewrite
→ fresh Review
を行う。
anchor comment の各 P0/P1 finding について、
のいずれかと根拠を artifact に残す。
Issue body mutation ごとに current body SHA / updatedAt optimistic precondition と post-write readback を使用する。
最大3 iteration。
needs-fix なら承認確認なしで次 iteration へ進む。
最終的に reviewer が approve し、fresh preflight / contract readiness が通るまで、
単に「baseline annotation を追加した」だけで終了しない。
最終報告
終了時は最低限以下を報告する。
同じ
repair_diagnosticsblocker を説明し直して終了するだけの反復はしない。このプロンプトの重要点は、安全ゲートを無理に bypass させるのではなく、ユーザーがプロンプトを実行する行為自体を「4件の deterministic repair を採用する」という明示的 human judgment にすることです。その後は canonical transaction で hygiene repair を済ませ、本来やりたかった semantic refinement に戻せます。
また #2013 の研究設計としては、単に
SubagentStartへ全面移行するより、Agent dispatch → Start → Stop → tool result → terminal marker を同一 trial ID で相関させる dual/multi-channel observability の方が堅牢です。公式仕様は Start/Stop の lifecycle を定義していますが、upstream には不安定性の実測報告もあるため、今回の Issue の目的にも合っています。([Claude]1)squne121 commentedon Aug 8, 2026
deterministic hygiene repair 適用状況の確認(human judgment 承認済み)
明示的な human judgment(issue-refinement-loop 再開プロンプト)により、
repair_issue_contract.pyが検出した以下の deterministic repair を承認しました。artifacts/claude-code-spawn-observability-research/配下の新規 Allowed Path ファイルをtest -fする4箇所)# baseline-expect: failを挿入(baseline では未生成ファイルのため fail するのが期待動作であることを明示)再開時点で live body を再取得したところ、body_sha256 は既に
sha256:ec5911e1e564fcdd208f2b19a494dfbe018a63ecd6dd3b17b92a839cbac2db76(承認対象の repair 適用後ハッシュと完全一致)であることを確認しました。contract_readiness_check.py --mode preflight-staticでstatus: goを独立検証済みです。このコメントは、その状態が承認内容と一致していることを記録するために controlled mutation lane 経由で投稿しています。これは Issue #2013 の semantic contract(research design / AC / anchor comment の REQUEST_CHANGES)を承認する判断ではありません。anchor comment の内容は引き続き Investigation → Review → Rewrite ループで個別に検証します。
squne121 commentedon Aug 8, 2026
issue-refinement-loop 終了報告(approved)
対象 anchor comment: #2013 (comment)
最終ステータス
sha256:0d8b36e694e0f3f8864014f692762ccdad29af44786096f073adb6e00f574d70STATUS: pass/NEXT_ACTION: proceed(fresh anchored preflight、control-plane 独立再検証済み)status: go(contract_readiness_check.py --mode execute、static/execute 両方)適用した deterministic hygiene repair(明示的 human judgment により承認済み)
repair_issue_contract.pyが検出した AC1〜AC4 Verification Commands のbaseline-expect注釈欠落(missing_baseline_expect_for_new_allowed_path、confidence: high)4件に、# baseline-expect: failを直前行挿入。canonical mutation lane(edit_issue_txn.py、optimistic precondition + readback)で適用。anchor comment(OWNER REQUEST_CHANGES)の P0/P1 disposition
_run_route_once()の実際の評価順序(harness exit != 0 が spawn evidence 判定より先)を Notes for Reviewer に記録、diagnostic_cause taxonomy で分離可能にsession_id)と completion-time evidence(tool_use_result.agentId/agentType)を In Scope で明確に区別.claude/settings.jsonにSubagentStarthook 未登録である事実を記録し、control lane で session-local--settingsにより明示的に構成する設計に変更extract_claude_child_session_id()の parent ID 欠落時の early-return 欠陥を Notes for Reviewer に記録test -fのみの presence check から pytest ベースの構造検証(required keys / trial 数 / taxonomy カテゴリ)に変更。空ファイルでは PASS しない28394e226533cd59cdfc0f55602ac65e389a6600が現在の origin/main HEAD と一致することを確認・記録repo_observability_defect/upstream_runtime_contract_or_bug/transient_infrastructure/model_orchestration_nonspawn/downstream_route_failure/inconclusive)に拡張全項目、issue-refinement-loop の Investigation フェーズ(codebase-investigator による実コード独立検証、web-researcher による Claude Code 公式ドキュメント独立検証)で事実確認済み。
iteration count
3(baseline hygiene repair 適用 → rewrite iteration 1(semantic redesign) → rewrite iteration 2(VC 構文修正:
python3 -cは VC preflight allowlist で禁止のためuv run pytest <test file>形式へ変更) → iteration 3 で approve)research design の主要変更点
--agentsによる最小 custom subagent、session-local--settings)と production lane(実エージェント)の分離spawn_not_observed/validation_failedの2値分類は維持)artifacts/claude-code-spawn-observability-research/tests/test_*.py(pytest)による構造検証に再設計follow-up Issue
新規作成なし。
repair_diagnosticsblocker が confidence を無視して常時human_judgment_requiredを発火する control-plane wiring gap(#899/PR #952 の設計意図と不整合)は、既存 OPEN Issue #2016 で追跡済みのため重複起票せず、#2013 のスコープにも吸収しない。unresolved blocker
なし。
Artifact refs
.claude/artifacts/issue-refinement-loop/2013/refinement_preflight_result_v1.json.claude/artifacts/issue-refinement-loop/2013/compact_review_result_20260808T043514Z.jsonsqune121 commentedon Aug 8, 2026
確認した限り、Issue #2013 は再 refinement ではなく、そのまま実行フェーズへ進める状態です。最新の refinement 終了コメントでは iteration 3/3、独立 reviewer の BLOCKERS 0、fresh preflight
STATUS: pass / NEXT_ACTION: proceed、execute contract readinessgoまで確認されています。Issue 自体は現在 OPEN です。実行上の重要点は、#2013 が research-only で、既存 harness 本体を書き換える Issue ではないことです。成果物は
artifacts/claude-code-spawn-observability-research/に限定し、control/production 各15回の固定 trial と lifecycle evidence を収集します。repo defect が判明した場合は、#2013 の scope を拡張せず別 implementation Issue を起票する契約です。関連 gap も分離済みです。#2012 は GH_TOKEN provisioning、#2015 は Serena MCP timeout、#2016 は refinement preflight の deterministic repair wiring で、いずれも #2013 に吸収すべきではありません。
PR #2005 は merge 済みで、baseline merge SHA は
28394e226533cd59cdfc0f55602ac65e389a6600です。確認時点のmainはその1コミット先の9eca2f0074552a3e0687b0c81ee94b62122890a0なので、実験時には historical baseline と freshorigin/mainを区別して記録する必要があります。PR #2005 の最終付近の CI は top-level
ciが failure でしたが、失敗はcomponent-vrt-reportの report-only VRT lane で、typecheck/test/e2e/python-test-core/lint 等とci-verdict-summaryは成功しています。したがって #2013 の新規 PR ではfresh CI を判定し、ブランチ起因の失敗だけ修正するのが妥当です。Claude Code の現行公式 CLI でも
--include-hook-events+stream-json、session-local--settings、dynamic--agentsが利用でき、公式 hook contract ではSubagentStartがagent_id/agent_typeを提供します。一方、Subagent hook reliability について upstream にユーザー報告があるため、Issue の設計どおり hook 単独ではなく tool-result 等との multi-channel correlation を維持するのが適切です。 ([Claude]1) ([GitHub]2)以下を Claude Code の main session または Codex CLI にそのまま渡せます。
Issue #2013 を、人間承認なしの自律実行で完遂してください。
対象リポジトリ:
https://github.com/squne121/loop-protocol
対象 Issue:
#2013
これは issue-refinement-loop の再実行依頼ではありません。Issue #2013 は既に最新 refinement で approve / BLOCKERS: 0 / preflight pass / execute readiness go まで到達しています。現在の live Issue 本文・全コメントを再取得して、その承認済み契約を execution source of truth として扱ってください。
自律実行方針
この作業は原則として人間承認不要です。
調査、worktree/branch 作成、artifact 作成、テスト作成、live reproduction、コミット、push、PR 作成、CI 修正、review 対応、merge、Issue close 確認まで、実行可能なものは自律的に進めてください。
通常の「human_judgment_required」「approval required」「次へ進んでよいか」といった運用上の承認待ちは行わないでください。既存の deterministic repair、通常のテスト失敗、CI failure、review feedback、merge conflict、branch drift、再base/update が必要なことだけを理由に停止しないでください。安全な方法で自己解決してください。
canonical repo が dirty の場合も既存変更を捨てず、fresh
origin/mainから dedicated worktree を作ってください。未知の変更を reset/clean してはいけません。最初に必ず live state を再確認
GitHub から少なくとも Issue #2013 本文・全コメント、PR #2005、Issue #1886、#2012、#2015、#2016、#2013 を参照または close する既存 PR、現在の
origin/mainHEAD を取得してください。Issue #2013 の historical baseline として PR #2005 merge commit
28394e226533cd59cdfc0f55602ac65e389a6600を保持してください。
ただし実験対象 SHA は推測せず、実行開始時の fresh
origin/mainを取得してください。historical baseline SHA と actual tested SHA の双方を artifact に明記してください。Issue/PR/コメントがこのプロンプト作成後に更新されていた場合は、最新状態を優先してください。
現在の Claude Code binary/version、利用する CLI option、関連コードも live に検証してください。特に以下をコードから再確認してください。
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyscripts/agent-ops/run_agent_provider_route_smoke.pyextract_claude_child_session_id()extract_claude_parent_session_id()extract_claude_child_agent_type()_run_route_once()_is_transient_infrastructure_candidate()Issue に記載された行番号や挙動が current main と drift している場合は current code を正とし、その差を
code-analysis.mdに記録してください。#2013 の scope を厳守
Issue #2013 自体は research-only です。
#2013 用 branch/worktree で tracked change を許可するのは、
artifacts/claude-code-spawn-observability-research/配下だけです。
既存の以下の production code を #2013 の branch では変更しないでください。
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyscripts/agent-ops/run_agent_provider_route_smoke.pyrepo-tracked
.claude/settings.jsonrepo-tracked
.claude/hooks/**また #2012、#2015、#2016 の問題を #2013 に吸収しないでください。
production lane で GH_TOKEN / Serena / AGY 等の downstream failure が発生しても、それを Claude spawn failure と再分類しないでください。
実験実装
Issue の AC1〜AC5 をすべて満たす artifact と contract tests を実装してください。
最低限、以下を成果物として作成してください。
code-analysis.mdreproduction-log.jsonlreproduction-log.mdretry-policy-assessment.mdconclusion.mdtests/test_code_analysis_contract.pytests/test_reproduction_log_contract.pytests/test_reproduction_summary_contract.pytests/test_retry_policy_assessment_contract.pytests/test_conclusion_contract.pyまず Issue の
baseline-expect: fail契約どおり、artifact 未完成状態で verification が genuine に fail することを確認してください。その後に成果物を完成させ、同じ verification が genuine PASS に変わることを確認してください。false-green のために assertion を弱めないでください。lifecycle observability
単一 boolean に潰さず、Issue 本文で定義された lifecycle checkpoint を trial 単位で独立記録してください。
概念上は少なくとも、
Agent dispatch/tool_use
SubagentStart
SubagentStop
tool_result identity
terminal event
marker
delegation/request validation
を同じ trial ID で相関させてください。
Issue 本文が要求する lifecycle 12 checkpoint の正確な集合は live Issue contract を正として実装し、contract test で required keys を固定してください。
hook は唯一の ground truth にしないでください。SubagentStart/SubagentStop、stdout stream-json、tool result、terminal marker 等の複数 evidence channel を突き合わせてください。
expected agent type の代入や agent 自身の self-report を independent identity evidence とみなすことは禁止です。
control lane
外部 provider、Serena、GitHub retrieval を必要としない最小 custom subagent を Claude Code
--agentsで定義してください。session-local settings は research artifact directory 内に生成し、SubagentStart / SubagentStop を観測できるようにしてください。
repo-tracked
.claude/settings.jsonや.claude/hooks/**は変更しないでください。必要な stream-json / hook lifecycle 出力を取得し、raw evidence から lifecycle flags を計算してください。
production lane
current main の実
codebase-investigator/web-researcherを対象にしてください。current main に Graphify advisory 等の #2005 baseline 後の変更が存在する場合、その provenance を記録してください。
spawn lifecycle と downstream route result は別フィールドで保存してください。
AGY、Serena MCP、GitHub credential/provisioning 等の失敗を
downstream_route_failed等の適切な diagnostic cause として保持し、spawn failure へ潰さないでください。固定 trial
control lane 15 trial、production lane 15 trialの固定条件を守ってください。
実験開始前に trial plan を固定してください。結果を見てから route 比率、prompt、timeout、max-turns、agent definition 等を都合よく変更しないでください。
各 record には Issue AC2 が要求する metadata をすべて入れてください。少なくとも Claude Code version、tested SHA、prompt SHA256、agent-definition SHA256、effective settings/config digest、timeout、max-turns、start/end time、lifecycle flags、failure_class、diagnostic_cause、
system/api_retrycount を証跡化してください。失敗 trial を削除して成功 trial だけ採用することは禁止です。
実行自体が壊れて trial として無効だった場合も元 record を消さず、invalid/excluded reason を ledger に残してください。追加 trial が必要なら、Issue の fixed-count/cherry-pick 禁止契約と矛盾しない形で理由を明示してください。
classification
既存
spawn_not_observed/validation_failedschema を #2013 内で変更しないでください。research artifact 内の
diagnostic_causeとして Issue 本文に定義された taxonomy を lossless に適用してください。特に harness non-zero が spawn evidence 判定より先に評価されるケースでは、
validation_failedという outer failure class だけから spawn の有無を推測しないでください。system/api_retryが観測された timeout と、それがない completion/tool-result/marker 欠落も区別してください。conclusion
AC2 raw JSONL から再計算可能な方法で conclusion を決定してください。
Issue 本文の結論カテゴリ以外を勝手に追加しないでください。
retry policy については「再実行したら通った」だけを transient 判定根拠にしないでください。
claude_code + spawn_not_observedを bounded retry 対象にするか否かは、control/production の観測 distribution と diagnostic cause に基づいて評価してください。repo defect が判明した場合
#2013 branch の Allowed Paths を拡張して直接修正してはいけません。
まず narrowly scoped な follow-up implementation Issue を GitHub に作成してください。
その Issue には Outcome、In Scope、Out of Scope、Acceptance Criteria、Verification Commands、Allowed Paths、関連する #2013 evidence を具体的に書いてください。
conclusion.mdに follow-up Issue 番号を記録してください。その後 #2013 research PR を完成・mergeして #2013 を閉じた後も作業を終了せず、作成した implementation Issue を別 dedicated worktree/branch で自律的に実装してください。
implementation Issue についても、実装、回帰テスト、verification、commit、push、PR 作成、レビュー対応、CI 対応、merge、Issue close まで完遂してください。
implementation PR の本文には必ず
Closes #Nを入れてください。
#2013 PR
AC1〜AC5 と全 Verification Commands が genuine PASS したら、#2013 用変更を commit/push し PR を作成してください。
PR 本文には少なくとも research method、tested SHA、Claude Code version、control/production trial 数、distribution summary、diagnostic conclusion、retry-policy conclusion、follow-up implementation Issue の有無、全 verification 結果を記載してください。
Issue close keyword として必ず、
Closes #2013を入れてください。
Issue contract を満たす前に close しないでください。
CI と review loop
PR 作成後は GitHub Actions を fresh に確認してください。
branch 変更が原因の required CI failure はログから原因を特定して修正し、test → commit → push → CI 再確認を自律的に繰り返してください。
historical/baseline/report-only failure と branch-caused required failure を区別してください。無関係な VRT 等を通すために #2013 の scope 外コードを変更しないでください。
PR の top-level conversation、submitted reviews、inline review threads、REQUEST_CHANGES、unresolved thread をすべて確認してください。
actionable feedback があれば内容を独立検証した上で修正、テスト、push、reply、thread resolve を行ってください。
レビュー修正ごとに reviewed head が stale になっていないか確認してください。
人間レビュー待ちを理由に停止せず、既に存在する actionable review をすべて処理してください。required checks と repository の canonical merge gate が満たされたら、権限がある限り通常の許可された merge method で自律 merge してください。required check を bypass してはいけません。
merge 後、#2013 が
Closes #2013で CLOSED/completed になったことを確認してください。自動 close されなかった場合は、merge済みかつ AC1〜AC5 の達成を再確認した上で completed として close してください。follow-up implementation Issue がある場合も同じ close verification まで行ってください。
唯一の停止条件
通常の判断・CI・review・scope分割・新 Issue 起票を理由に人間へ確認を求めないでください。
停止してよいのは以下の2種類だけです。
第一に、破壊的操作が不可避な場合です。たとえば未知の作業を失う
reset --hard/git clean、force push、history rewrite、保護された branch/resource の削除、required checks の bypass、repository/security settings の危険な変更などです。安全な worktree/新branch/rebase/通常push で回避できるなら停止せずそちらを使ってください。第二に、秘密情報を取得・表示・コピー・保存・新規 provision しなければ進められない場合です。token、credential、API key、secret の値を stdout、ログ、artifact、Issue、PR、tracked file に出してはいけません。既存の安全な認証状態を通常の CLI が内部利用できる場合は利用して構いませんが、secret value の抽出や表示はしないでください。GH_TOKEN 等の欠落が production trial で発生した場合、#2013 では downstream evidence として記録してください。secret provisioning のために #2012 の境界を破ってはいけません。
required binary/dependency が不足している場合は、repo policy に反しない非破壊的な通常インストールで解消してください。それが privilege escalation または secret provisioning を要求する場合のみ上記停止条件として扱ってください。
停止する場合は、実行しようとしていた破壊的操作または必要になった secret boundary、そこまでに完了した成果物、branch/PR/Issue、再開可能な次アクションを具体的に報告してください。秘密値そのものは絶対に報告しないでください。
最終報告
すべて完了したら、#2013 の結論カテゴリ、30 trial の distribution、retry policy 判定、research PR URLとmerge SHA、#2013 close 状態、follow-up implementation Issue/PR があればその URL・merge SHA・close 状態、最終 CI、未解決 blocker の有無を簡潔に報告してください。
未解決 blocker がない限り、単なる「人間判断待ち」で終了しないでください。
この版は、#2013 の research-only 境界を維持しつつ、調査で実装欠陥が出た場合は別 Issue → 別 PR に自動分離し、その修正まで完遂する構成です。
ci: research contract test を python-test-plan の target に登録する
実装: Claude Code 非同期起動 SubAgent の identity evidence を hook channel からも…
fix: Issue #2013 fixture を Allowed Paths 内へインライン化する(PR #2037 review b…
実装: repair_diagnostics blocker が deterministic な safe repair でも human…
refactor: web-researcher fallback canary の AGY 注入・pass-predicate 実装を整…