Skip to content

refactor: オーケストレーター 2 件 (impl-review-loop + issue-refinement-loop) を LOOP_PROTOCOL 用に適合 (phase C-4b) - #21

Merged
squne121 merged 3 commits into
mainfrom
worktree-c4b-loop-orchestrators-adapt
May 19, 2026
Merged

squne121 merged 3 commits into
mainfrom
worktree-c4b-loop-orchestrators-adapt

Conversation

@squne121

Copy link
Copy Markdown
Owner

Summary

C-4 後半。adversarial-review を採用しない方針(PR #12)に従い、両オーケストレーターから Step 3(adversarial review)と Step 1.5(spec document review)を撤去し、PR #17 で確立した「SubAgent = 役割、Skill = 作業手順」モデルに沿って構造を簡素化しました。

ファイル 行数変化
impl-review-loop/SKILL.md 142 → 106
impl-review-loop/steps/preparation.md 500 → 68
impl-review-loop/steps/step-1-implementation.md 184 → 60
impl-review-loop/steps/step-2-verification.md 183 → 50
impl-review-loop/steps/step-4-pr-review.md 104 → 52
impl-review-loop/steps/step-5-feedback-and-termination.md 383 → 77
impl-review-loop/steps/step-5-mergeability-handling.md 185 → 61
impl-review-loop/steps/conflicting-pr-escalation-runbook.md 105 → 70
impl-review-loop/steps/context-protocol-and-guardrails.md 67 → 52
impl-review-loop/steps/step-1-5-spec-document-review.md 70
impl-review-loop/steps/step-3-adversarial-review.md 254
issue-refinement-loop/SKILL.md 956 → 200
issue-refinement-loop/references/issue-ops-and-handoff-sidecar.md 136 → 54

差分: +613 / -3,032 行(2,419 行削減)

主な変更

impl-review-loop(実装→検証→PR レビュー ループ)

  • ループ構造を 3 ステップに簡素化: 実装 → 検証 → PR レビュー
    • Step 番号は履歴互換のため 1 → 2 → 4 → 5 のまま保持
  • LOOP_STATE YAML を control-plane の正本として明示
  • 責務分離原則を表で明示(implementation-worker / test-runner / pr-reviewer)
  • LOOP_VERDICT 抽出を「最新コメント時系列ソート」に統一(reviews と comments を merge)
  • CONFLICTING PR Escalation を独立ステップとして整理

issue-refinement-loop(Issue 本文改善ループ)

  • 4 段ループ → 3 段ループ(調査 → レビュー → 改善ライト)
  • Step 4 で issue-author SubAgent + edit-issue skill 経由の書き戻しに統一(PR refactor: Issue 管理系 skill / agent を LOOP_PROTOCOL 用に適合 (phase C-1) #17 で確立した「SubAgent = 役割、Skill = 手順」モデル)
  • Critical Guard(refinement では AC を実行しない / baseline fail は正常動作)を維持
  • references/sidecar.md を Parent Mode / GitHub Ops Logging / Scope 変更検出に集約

共通: 除去した残骸

  • adversarial-review / adversarial-reviewer 参照(不採用方針)
  • spec-document-reviewer / spec document review step
  • CodexCLI / gpt-5.x モデル指定例
  • .agents/rules/ / .agents/skills/shared-agent-skills-governance/
  • .kiro/steering/ 参照
  • KindleAudiobookMakeSystem 固有 Issue / PR 番号
  • Rules Loading Preflight / role manifest 抽出 inline 注入機構
  • Human Intent Ledger(decision-only で代替可能、現状不要)
  • 大量のフォローアップ条件 / 復旧分岐(簡素化)
  • ## Use When セクション(description で代替)

検証

  • pnpm typecheck ✅
  • pnpm lint ✅
  • pnpm test ✅ (4 files / 5 tests)
  • pnpm build ✅
  • 残存パターン 2 件は「adversarial-review を採用しない」旨の意図的注記(除去対象外)

C-4 完了

本 PR で C-4(オーケストレーション系)を完了します:

関連

🤖 Generated with Claude Code

…LOOP_PROTOCOL 用に適合 (phase C-4b)

C-4 後半。adversarial-review を採用しない方針 (PR #12) に従い、両オーケストレーターから
Step 3 (adversarial review) と Step 1.5 (spec document review) を撤去し、構造を簡素化。

スコープ:
- .claude/skills/impl-review-loop/SKILL.md (142 → 106 行)
- .claude/skills/impl-review-loop/steps/preparation.md (500 → 68 行)
- .claude/skills/impl-review-loop/steps/step-1-implementation.md (184 → 60 行)
- .claude/skills/impl-review-loop/steps/step-2-verification.md (183 → 50 行)
- .claude/skills/impl-review-loop/steps/step-4-pr-review.md (104 → 52 行)
- .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md (383 → 77 行)
- .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md (185 → 61 行)
- .claude/skills/impl-review-loop/steps/conflicting-pr-escalation-runbook.md (105 → 70 行)
- .claude/skills/impl-review-loop/steps/context-protocol-and-guardrails.md (67 → 52 行)
- .claude/skills/impl-review-loop/steps/step-1-5-spec-document-review.md (70) → 削除 (KindleAudiobook 固有)
- .claude/skills/impl-review-loop/steps/step-3-adversarial-review.md (254) → 削除 (adversarial 不採用)
- .claude/skills/issue-refinement-loop/SKILL.md (956 → 200 行)
- .claude/skills/issue-refinement-loop/references/issue-ops-and-handoff-sidecar.md (136 → 54 行)

主な変更:

### impl-review-loop
- ループ構造を 3 ステップに簡素化: 実装 → 検証 → PR レビュー (Step 番号は履歴互換のため 1→2→4→5 のまま保持)
- LOOP_STATE YAML を control-plane の正本として明示
- 責務分離原則を表で明示 (implementation-worker / test-runner / pr-reviewer)
- LOOP_VERDICT 抽出を最新コメント時系列ソートに統一
- CONFLICTING PR Escalation を独立ステップとして整理

### issue-refinement-loop
- 4 段ループ → 3 段ループ (調査 → レビュー → 改善ライト)
- Step 4 で issue-author SubAgent + edit-issue skill 経由の書き戻しに統一 (PR #17 で確立した SubAgent = 役割 / Skill = 手順モデル)
- Critical Guard (refinement では AC を実行しない) を維持
- references/sidecar.md を Parent Mode / GitHub Ops Logging / Scope 変更検出に集約

### 共通: 除去した残骸
- adversarial-review / adversarial-reviewer 参照 (不採用方針)
- spec-document-reviewer / spec document review step
- CodexCLI / gpt-5.x モデル指定例
- .agents/rules/, .agents/skills/shared-agent-skills-governance/
- .kiro/steering/ 参照
- KindleAudiobookMakeSystem 固有 Issue/PR 番号
- Rules Loading Preflight / role manifest 抽出 inline 注入機構
- Human Intent Ledger (decision-only に置き換え可能、現状不要)
- 大量のフォローアップ条件 / 復旧分岐 (簡素化)
- Use When セクション (description で代替)

検証:
- pnpm typecheck / lint / test (5) / build すべて通過
- 残存パターンの 2 件は「adversarial-review を採用しない」旨の意図的注記

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
PR #21 のレビュー指摘 5 件 (r3265791383, r3265797212, r3265813497, r3265820430,
r3265826768) + 人間承認原則の追加方針を反映する。

## 局所修正

- impl-review-loop/SKILL.md L34 (責務分離原則章) → docs/dev/agent-skill-boundaries.md へ移動
- impl-review-loop/steps/context-protocol-and-guardrails.md L31 (control-plane / data-plane), L50 (Context 効率) → docs/dev/agent-skill-boundaries.md へ移動。本ファイルは作業手順だけに削減 (52 → 25 行)
- issue-refinement-loop/SKILL.md L41 (責務分離原則章) → docs/dev/agent-skill-boundaries.md へ移動
- issue-refinement-loop/references/issue-ops-and-handoff-sidecar.md (54 行) → 削除。GitHub Ops ルールは docs/dev/github-ops.md に集約

## 横断: 設計原則の docs/dev/ への集約

新規ファイル + 拡張:
- docs/dev/agent-skill-boundaries.md: 「オーケストレーター設計原則」セクションを追加 (+56 行):
  - control-plane / data-plane の分離
  - ループ内の人間承認原則 (新規)
  - LOOP_STATE による状態管理
  - Context 効率 (既存コンテクスト最大活用)
  - 無限ループ防止と冪等性
- docs/dev/github-ops.md (新規 119 行):
  - Body File Guidance (gh issue/pr edit/comment 共通)
  - Pre-edit guard (空ファイル / HEREDOC エスケープ検知)
  - HEREDOC 内コードフェンス規約 (~~~ 推奨)
  - Parent Issue Machine-Readable Contract enum + fail-close
  - Issue / PR コメント記録プロトコル (iteration 開始 / 完了 / ループ終了テンプレ)
  - 認証 / リポジトリ指定 / ラベル運用

## 人間承認原則 (新規方針)

ユーザーがループを起動した時点でループ全体の実行が承認されているため、ループ内では以下を追加承認なしに自動進行する:
- イテレーション継続判断 (REQUEST_CHANGES → 次イテレーション)
- Issue 本文の修正適用 (refinement loop 中の書き戻し)
- 各 Step 間の SubAgent 委譲

例外 (人間判断を仰ぐ): max_iterations 超過 / SubAgent からの human_review_required: true / 想定外エラー。

詳細は docs/dev/agent-skill-boundaries.md「ループ内の人間承認原則」セクション。

## 結果

- skill / step ファイルは作業手順に専念 (設計記述を排除)
- 開発運用ドキュメントが設計原則 + GitHub 運用ルールの SSOT になる
- 検証: pnpm typecheck / lint / test (5) / build すべて通過

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

レビュー指摘 5 件 + 「ループ内人間承認原則」を反映して push しました(07fe881)。

コメント別の対応

Discussion 対応
r3265791383 (control-plane / data-plane は設計) docs/dev/agent-skill-boundaries.md に「オーケストレーター設計原則」セクションを新設して移動
r3265797212 (既存コンテクスト最大活用) docs に「Context 効率(既存コンテクスト最大活用)」原則を追記
r3265813497 (impl-review-loop SKILL.md の責務分離原則) SKILL.md から削除 → docs に集約。skill 側は作業手順だけに
r3265820430 (GitHub 運用ルール) docs/dev/github-ops.md を新設 (119 行)。Body File Guidance / Pre-edit guard / Parent Mode / コメント記録テンプレを集約
r3265826768 (refinement-loop SKILL.md の責務分離) SKILL.md から削除 → docs に集約

横断: 人間承認原則の明示(新規方針)

docs/dev/agent-skill-boundaries.md に「ループ内の人間承認原則」セクションを追加:

ユーザーがループを起動した時点でループ全体の実行が承認されている。ループ内の以下では追加の人間承認を求めない:

  • イテレーション継続判断(REQUEST_CHANGES → 次イテレーション)
  • Issue 本文の修正適用(refinement loop 中の書き戻し)
  • 各 Step 間の SubAgent 委譲

例外(人間判断を仰ぐ): max_iterations 超過 / human_review_required: true / 想定外エラー

両ループ skill とも、上記原則に従って routine 操作は SubAgent 経由で自動進行する設計に整合済み。

ファイル整理結果

ファイル 変化
impl-review-loop/SKILL.md 106 → 97(責務分離原則を docs に移動)
impl-review-loop/steps/context-protocol-and-guardrails.md 52 → 25(設計記述を docs に移動)
issue-refinement-loop/SKILL.md 200 → 192(責務分離原則を docs に移動、sidecar 参照を更新)
issue-refinement-loop/references/issue-ops-and-handoff-sidecar.md 54
docs/dev/agent-skill-boundaries.md 107 → 163
docs/dev/github-ops.md 0 → 119

差分: +199 / -122 行

検証

  • pnpm typecheck / lint / test (5) / build 全通過
  • skill / step は作業手順に専念、設計記述は docs に集約

差し戻し・追加修正があればお知らせください。

PR #21 のレビューコメント r3265905380 を反映する。

「設計原則は docs を正本とする」「本 skill は作業手順に専念する」といった meta 記述
それ自体が context 汚染。skill ファイルに書く意味はない (エージェントの作業品質を
向上させないし、トークンを消費するだけ)。

横断的に同パターンを除去:

- impl-review-loop/SKILL.md: 冒頭 meta 段落を削除 (97 → 95 行)
- impl-review-loop/steps/context-protocol-and-guardrails.md: 冒頭 meta 段落を削除 (25 → 23 行)
- issue-refinement-loop/SKILL.md: Loop Structure 直後の meta 段落を削除 (192 → 190 行)

skill ファイル冒頭は description + 必要な手順だけにし、設計原則は docs/dev/ に独立して
存在することは Related セクション末尾のリンクだけで示す。

検証: pnpm typecheck / lint / test (5) / build すべて通過

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

追加指摘 r3265905380 を反映して push しました(05ff914)。

この設計に関する話をそもそもエージェントスキル内に書かなくていい。という指摘。現在の記述によってエージェントの作業品質は向上するのか?トークンを消費し、コンテクストを汚染しているだけでは?

ご指摘どおり、「設計原則は docs を正本とする」「本 skill は作業手順に専念する」という meta 記述自体が context 汚染 でした。横断的に同パターンを除去:

ファイル 変化
impl-review-loop/SKILL.md 97 → 95(冒頭 meta 段落削除)
impl-review-loop/steps/context-protocol-and-guardrails.md 25 → 23(冒頭 meta 段落削除)
issue-refinement-loop/SKILL.md 192 → 190(Loop Structure 直後の meta 段落削除)

skill ファイル冒頭は description + 必要な手順だけにし、設計原則が docs/dev/ に独立して存在することは Related セクション末尾のリンクで示すだけにしました。

差分: -6 行。検証コマンド全通過。

@squne121
squne121 merged commit a5f2ba6 into main May 19, 2026
4 checks passed
@squne121
squne121 deleted the worktree-c4b-loop-orchestrators-adapt branch May 19, 2026 11:37
squne121 added a commit that referenced this pull request May 19, 2026
#22)

* refactor: 補助系 (codebase-investigator) を LOOP_PROTOCOL 用に適合 (phase C-5)

設計記述・責務境界の長い説明を agent ファイルから削除(PR #21 の方針: 設計は
docs/dev/agent-skill-boundaries.md に集約、agent / skill は作業手順に専念)。

スコープ:
- .claude/agents/codebase-investigator.md (93 → 64 行)

主な変更:
- 「責務境界: ローカルコード調査専念」セクション削除(設計記述)
- 「役割と責務」「制約」の冗長記述削除(description と disallowedTools で表現)
- web-researcher への委任フロー → gemini-cli-headless-delegation 経由 (呼び出し元の責務として簡素化)
- 入力契約をコンパクトに

web-researcher は保留方針 (PR #12) のため本 PR では触らない。

検証: pnpm typecheck / lint / test (5) / build すべて通過

これで Phase C (流用 skill / agent の LOOP_PROTOCOL 適合) が完了:
- C-1: Issue 管理系 (PR #17 マージ済み)
- C-2: 実装系 (PR #18 マージ済み)
- C-3: レビュー系 (PR #19 マージ済み)
- C-4a: open-pr + post-merge-cleanup (PR #20 マージ済み)
- C-4b: impl-review-loop + issue-refinement-loop (PR #21 マージ済み)
- C-5: 補助系 (本 PR)

次は Phase D (統合検証)。

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor: PR #22 レビュー指摘を反映 — codebase-investigator は必ず gemini-cli-headless-delegation 経由で委譲

PR #22 のレビュー指摘 r3266005474 を反映する。

> .claude/agents/codebase-investigator.md も gemini-cli-headless-delegation で必ず作業を委譲するようにして。

実調査 (Read / Grep / Glob による大規模スキャン) はすべて gemini-cli-headless-delegation
skill 経由で Gemini に委譲する設計に変更。本 SubAgent 自身はリクエスト構築 + 委譲 +
結果整形に専念する。

主な変更:

- tools から Grep / Glob を削除 (disallowedTools に移動して技術的にもブロック)
- 残った tools: Bash (wrapper 起動) + Read (結果読み取り)
- 振る舞いセクションを「実調査は Gemini に委譲」と明示
- 入力モードを 2 種類定義し、それぞれの delegation_request_v1 JSON 雛形を例示
  - ローカル調査モード: tool_profile=local_asset_research, role=code_research
  - gh 調査モード: tool_profile=github_research, role=github_research, gh_commands で gh issue list を委譲実行
- 報告形式に「委譲メタ」(wrapper exit / model / request path) を追加
- 委譲不可時 (wrapper ok: false、preflight 失敗) は fail-close (自力代替調査しない)

検証: pnpm typecheck / lint / test (5) / build すべて通過

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant