Skip to content

実装: issue-refinement-loop の SubAgent 起動を planner-declared launch plan に制限する #1288

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "issue-refinement-loop の SubAgent 起動を planner-declared launch plan に拘束し、placeholder 起動と重複調査を決定論的に止める"
change_kind: code

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: refinement loop 中の SubAgent 起動が planner output に宣言されたものだけになる
  • Desired Destination: placeholder 起動・同一 claim の重複 investigation・raw transcript の main context 混入がゼロになる

Current Validated Scope

  • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py の output に subagent_launch_plan を追加
  • scripts/check_subagent_launch_ledger.py に launch plan 照合検証を追加
  • launch plan / ledger policy テストの追加

Remaining Parent Gaps

  • SubAgent 起動を runtime で hard block する hook 化(SubAgentStart 相当)は、ledger 検出で不足が確認された場合の follow-up とする
  • reviewer claim replay の taxonomy parity は別 Issue で扱う

Outcome

plan_refinement_loop.py が subagent_launch_plan(allowed_launches / forbidden_launches / cheap_probe_required_first)を出力し、check_subagent_launch_ledger.py が plan 外起動・placeholder prompt・同一 issue/claim/path の重複 investigation を violation として決定論的に検出し、対応テストが CI で PASS している状態。

Background

#1277 の refinement 作業ログでは、不要な placeholder agent が誤起動され直後に無視され、また anchor claim の検証で codebase-investigator を使った後に同じ事実を grep / read で再確認する重複調査が発生した。issue-refinement-loop は Step 1 investigation を planner が required と判断した場合のみ行う設計だが、SubAgent 起動そのものを planner output に拘束する runtime check が弱い。docs/dev/agent-skill-boundaries.md は root thread を control-plane、worker を data-plane とし、ledger evidence を canonical とする方針を既に持つ。

In Scope

  • subagent_launch_plan の schema 追加(agent / reason_code / max_prompt_chars / expected_artifact_schema / cheap_probe_required_first を持つ allowed_launches、および forbidden_launches)
  • check_subagent_launch_ledger.py への検証追加: plan 外起動は violation、placeholder / status check / 空 prompt は violation、同一 issue + claim + path set の 2 回目以降 investigation は duplicate_investigation
  • SubAgent output を artifact ref + 短い summary に制限する契約の ledger 検証
  • テスト追加と scripts/python-test-plan.json 登録

Out of Scope

  • SubAgent 起動の realtime hard block hook の新設(検出は ledger ベースで行い、hook 化は follow-up)
  • issue-reviewer / codebase-investigator の agent 定義変更
  • refinement loop 以外の skill への launch plan 展開

Acceptance Criteria

  • AC1: planner output にない SubAgent 起動が ledger 検証で violation として検出される
  • AC2: prompt が placeholder / status check / 空に近い SubAgent 起動が violation として検出される
  • AC3: cheap_probe_required_first が真の場合、grep / read / schema probe の inconclusive artifact なしの codebase-investigator 起動が violation になる
  • AC4: SubAgent output が artifact ref + 5 行以内 summary の契約を破る場合に violation として検出される
  • AC5: 同一 issue / claim / path の investigation が 2 回目以降 duplicate_investigation として検出される

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py::test_ac1_unplanned_launch_detected -q
# AC2
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py::test_ac2_placeholder_prompt_detected -q
# AC3
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py::test_ac3_cheap_probe_required_first_enforced -q
# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py::test_ac4_output_bounded_artifact_ref_summary -q
# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py::test_ac5_duplicate_investigation_detected -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
  • .claude/skills/issue-refinement-loop/tests/test_subagent_launch_plan.py
  • .claude/skills/issue-refinement-loop/SKILL.md
  • scripts/check_subagent_launch_ledger.py
  • tests/test_subagent_launch_ledger_policy.py
  • tests/fixtures/subagent-ledger/
  • docs/dev/agent-skill-boundaries.md
  • scripts/python-test-plan.json

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Delta(任意)

N/A

Notes for Reviewer

  • 既存 ledger fixture(tests/fixtures/subagent-ledger/)の後方互換を維持し、追加 violation 種別は既存 schema の superset として実装する
  • REFINEMENT_LOOP_PLAN_V1 に subagent_launch_plan を追加する場合は planner consumer 側の後方互換(欠落時は現行挙動)を保つ

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jul 2, 2026
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

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions