Skip to content

調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013

Closed

Description

@squne121

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-only

Parent 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 commit 28394e226533cd59cdfc0f55602ac65e389a6600)が、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/SubagentStop hook event(公式スキーマ: agent_id, agent_type, agent_transcript_path, stop_reason, last_assistant_message 等)を、現行 harness が実際に parse・比較しているか確認する。リポジトリの .claude/settings.json には SubagentStop hook のみが登録され SubagentStart hook は未登録であることを踏まえ、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/SubagentStop hook 双方を 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・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_retry count を記録する。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_observed transient retry 対象化ロジック自体の変更(既存契約は維持する)。
  • run_refinement_preflight.py の repair_diagnostics blocker が 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/SubagentStop hook 自体を 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.py

Allowed 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 Objective
  • Bounded Current Context
  • Open Questions
  • Next Action
  • Artifact Refs

Notes for Reviewer

Activity

  1. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    Issue #2013 の方向性自体は妥当です。#1886 の OWNER 判断でも、PR #2005 のコード欠陥とは断定できなかった runtime prerequisite / reliability gap の一つとして #2013 が明示的に分離されています。

    ただし、現状の Issue 契約のまま調査を開始すると、spawn_not_observed の原因診断と retry 可否判定を誤る可能性があります。特に Claude Code の「spawn」と「Agent 完了結果」の観測が混同されています。

    優先度 | 指摘 | 問題 -- | -- | -- 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 判断には別分類が必要です。

    最も重要な技術的修正

    #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 を独立記録するのが適切です。

    Agent tool_use observed
            ↓
    SubagentStart(agent_id, agent_type)
            ↓
    SubagentStop(agent_id, agent_type)
            ↓
    Agent tool_result(tool_use_result.agentId/agentType)
            ↓
    ROUTE_SMOKE_DONE
            ↓
    delegation_request/result semantic validation
    

    これで例えば、

    Agent tool_use=yes
    SubagentStart=yes
    SubagentStop=no
    tool_result=no
    harness timeout=yes
    

    なら spawn_not_observed ではなく child completion timeout です。

    逆に、

    Agent tool_use=yes
    SubagentStart=yes
    SubagentStop=yes
    tool_result agentId=no
    

    なら、子 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秒です。したがって、

    system/api_retry observed
    → harness 180s timeout
    

    と

    API retryなし
    → Agent tool_resultだけ欠落
    → process exit 0
    

    を同じ validation_failed にしてはいけません。

    少なくとも research artifact 内では、

    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 を研究 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 は exact tested_head、Claude Code version、prompt SHA、agent-definition SHA、timeout/max-turns、試行数、上記 lifecycle の各 presence flag、system/api_retry count を記録する。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 完了結果」の観測が混同されています。

    優先度 指摘 問題
    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]1)
    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 28394e226533... として 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]3)
    P1-3 結論の三分類が不足 「repo defect / transient infra / 判別不能」だけでは、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 を独立記録するのが適切です。

    Agent tool_use observed
            ↓
    SubagentStart(agent_id, agent_type)
            ↓
    SubagentStop(agent_id, agent_type)
            ↓
    Agent tool_result(tool_use_result.agentId/agentType)
            ↓
    ROUTE_SMOKE_DONE
            ↓
    delegation_request/result semantic validation
    

    これで例えば、

    Agent tool_use=yes
    SubagentStart=yes
    SubagentStop=no
    tool_result=no
    harness timeout=yes
    

    なら spawn_not_observed ではなく child completion timeout です。

    逆に、

    Agent tool_use=yes
    SubagentStart=yes
    SubagentStop=yes
    tool_result agentId=no
    

    なら、子 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秒です。したがって、

    system/api_retry observed
    → harness 180s timeout
    

    と

    API retryなし
    → Agent tool_resultだけ欠落
    → process exit 0
    

    を同じ validation_failed にしてはいけません。

    少なくとも research artifact 内では、

    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 を研究 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 は exact tested_head、Claude Code version、prompt SHA、agent-definition SHA、timeout/max-turns、試行数、上記 lifecycle の各 presence flag、system/api_retry count を記録する。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 になります。

  2. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(human_judgment_required)

    対象 anchor comment: #2013 (comment)

    STATUS

    blocked / NEXT_ACTION: human_judgment_required(preflight 段階で停止、review/rewrite ループ未開始)

    停止理由

    1. 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 前段の構造ゲートです。
      • 検出内容: 各 VC の直前行に # baseline-expect: fail を挿入する提案(dry-run のみ、body 未変更)
      • artifact: .claude/artifacts/issue-refinement-loop/2013/repair_diagnostics.json
    2. anchor comment(OWNER REQUEST_CHANGES)は no_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)以降のループへ進めます。

    参考

    • anchor comment 全文は .claude/artifacts/issue-refinement-loop/2013/raw_issue_snapshot.json の anchor_comment.snapshot を参照してください。
  3. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    前回の 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 の

    repair_diagnostics は「常時 fail-closed の安全ゲート」だから人間専用

    という説明は、現在のコードの挙動説明としては正しい一方、リポジトリの設計履歴まで含めれば不十分です。より正確には「#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 だけで、SubagentStart hook は登録されていません。 したがって #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 を再開してください。

    対象:

    今回の 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-issue contract に従って 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.md
    • CLAUDE.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.py
    • scripts/agent-ops/run_agent_provider_route_smoke.py
    • scripts/agent-ops/validate_agent_provider_route_smoke.py
    • 関連 tests / fixtures / schemas

    可能なら最初に以下の 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 を一次情報で確認する。

    • Agent tool dispatch
    • SubagentStart
    • SubagentStop
    • agent_id
    • agent_type
    • stream-json
    • --include-hook-events
    • --settings
    • dynamic custom subagent (--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 が既に指定されている場合でも、
    実際に SubagentStart event を parser が consume しているかを確認する。

    failure taxonomy

    validation_failed / spawn_not_observed の現在の if/elif evaluation order をコードから再構成する。

    最終 boolean だけでなく、少なくとも次の lifecycle checkpoints を独立フィールドとして研究対象にする。

    1. parent Agent tool dispatch attempted
    2. SubagentStart observed
    3. SubagentStart agent_id observed
    4. SubagentStart agent_type matched
    5. SubagentStop observed
    6. Agent tool result observed
    7. tool-result agentId observed
    8. tool-result agentType matched
    9. process exit status
    10. terminal marker observed
    11. delegation request validation
    12. downstream provider/retrieval result

    spawn 前、spawn 済み、completion 待ち、wrapper failure、downstream route failure を一つの validation_failed に畳み込まない。

    研究用 diagnostic_cause taxonomy を定義し、少なくとも 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 がさらに進んでいる場合は、

    • historical baseline SHA
    • current observed main SHA
      を両方記録し、どちらを trial 対象にしたか明示する。

    silent に別 SHA へ置換しない。

    Acceptance Criteria / Verification Commands

    現在の test -f だけの VC は decisive false-green なので全面的に作り直す。

    空ファイル4枚で全AC PASSできないことを要求する。

    AC は少なくとも次を機械検証できる形にする。

    • pinned environment / versions / hashes / trial count
    • lifecycle event matrix
    • control-vs-production comparison
    • failure taxonomy
    • retry eligibility conclusion
    • raw JSONL/JSON artifact と Markdown summary の対応
    • required trial count を満たす
    • required fields が non-empty
    • lifecycle ordering / ID correlation
    • downstream failure と spawn failure の分離
    • conclusion が raw observations から再計算可能

    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 について、

    • confirmed
    • partially confirmed
    • rejected
    • superseded
      のいずれかと根拠を 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_diagnostics blocker を説明し直して終了するだけの反復はしない。

    このプロンプトの重要点は、安全ゲートを無理に 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)

  4. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    deterministic hygiene repair 適用状況の確認(human judgment 承認済み)

    明示的な human judgment(issue-refinement-loop 再開プロンプト)により、repair_issue_contract.py が検出した以下の deterministic repair を承認しました。

    • 対象: AC1〜AC4 の Verification Commands(artifacts/claude-code-spawn-observability-research/ 配下の新規 Allowed Path ファイルを test -f する4箇所)
    • 内容: 各 VC の直前行に # 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 ループで個別に検証します。

  5. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    対象 anchor comment: #2013 (comment)

    最終ステータス

    • verdict: approve(iteration 3/3、issue-reviewer 独立検証・BLOCKERS: 0)
    • final body SHA: sha256:0d8b36e694e0f3f8864014f692762ccdad29af44786096f073adb6e00f574d70
    • final preflight: STATUS: pass / NEXT_ACTION: proceed(fresh anchored preflight、control-plane 独立再検証済み)
    • final contract readiness: 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

    ID 判定 反映内容
    P0-1 confirmed → 反映済み _run_route_once() の実際の評価順序(harness exit != 0 が spawn evidence 判定より先)を Notes for Reviewer に記録、diagnostic_cause taxonomy で分離可能に
    P0-2 confirmed → 反映済み spawn-time evidence(session_id)と completion-time evidence(tool_use_result.agentId/agentType)を In Scope で明確に区別
    P0-3 confirmed → 反映済み .claude/settings.json に SubagentStart hook 未登録である事実を記録し、control lane で session-local --settings により明示的に構成する設計に変更
    P0-4 confirmed → 反映済み control lane(外部 provider 不要な最小 custom agent)と production lane(実 codebase-investigator/web-researcher)を分離し、#2012/#2015 相当の downstream failure を混入させない設計に
    P0-5 confirmed → 反映済み extract_claude_child_session_id() の parent ID 欠落時の early-return 欠陥を Notes for Reviewer に記録
    P0-6 confirmed → 反映済み AC1〜AC5 を再設計し、test -f のみの presence check から pytest ベースの構造検証(required keys / trial 数 / taxonomy カテゴリ)に変更。空ファイルでは PASS しない
    P1-1 confirmed → 解消済み PR #2005 merge commit 28394e226533cd59cdfc0f55602ac65e389a6600 が現在の origin/main HEAD と一致することを確認・記録
    P1-2 confirmed → 反映済み control/production 各 lane 15 trial(固定)、環境 pinning(version/SHA/digest等)を In Scope に明記
    P1-3 confirmed → 反映済み 結論 taxonomy を 6 分類(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 の主要変更点

    • lifecycle checkpoint(Agent tool dispatch〜terminal marker、12項目)の段階別観測設計
    • control lane(--agents による最小 custom subagent、session-local --settings)と production lane(実エージェント)の分離
    • 拡張 diagnostic_cause taxonomy(12種類)の導入(既存 spawn_not_observed/validation_failed の2値分類は維持)
    • 各 lane 15 trial(固定)+ 環境 pinning
    • AC1〜AC5 を artifacts/claude-code-spawn-observability-research/tests/test_*.py(pytest)による構造検証に再設計

    follow-up Issue

    新規作成なし。repair_diagnostics blocker が 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.json
  6. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    確認した限り、Issue #2013 は再 refinement ではなく、そのまま実行フェーズへ進める状態です。最新の refinement 終了コメントでは iteration 3/3、独立 reviewer の BLOCKERS 0、fresh preflight STATUS: pass / NEXT_ACTION: proceed、execute contract readiness go まで確認されています。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 と fresh origin/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/main HEAD を取得してください。

    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.py
    scripts/agent-ops/run_agent_provider_route_smoke.py

    extract_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.py
    scripts/agent-ops/run_agent_provider_route_smoke.py
    repo-tracked .claude/settings.json
    repo-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.md
    reproduction-log.jsonl
    reproduction-log.md
    retry-policy-assessment.md
    conclusion.md
    tests/test_code_analysis_contract.py
    tests/test_reproduction_log_contract.py
    tests/test_reproduction_summary_contract.py
    tests/test_retry_policy_assessment_contract.py
    tests/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_retry count を証跡化してください。

    失敗 trial を削除して成功 trial だけ採用することは禁止です。

    実行自体が壊れて trial として無効だった場合も元 record を消さず、invalid/excluded reason を ledger に残してください。追加 trial が必要なら、Issue の fixed-count/cherry-pick 禁止契約と矛盾しない形で理由を明示してください。

    classification

    既存 spawn_not_observed / validation_failed schema を #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 に自動分離し、その修正まで完遂する構成です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions