Skip to content

改善: issue-refinement-loop に「対象コメントが Issue 前提を覆す人間 Decision を含む場合」の分岐を追加する #96

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "issue-refinement-loop skill に、対象 Issue / コメントに Issue 前提を無効化する人間 Decision が存在する場合の分岐(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)を明文化し、refinement loop が前提否決済み Issue を誤って approve へ磨かないようにする"
change_kind: workflow

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: なし(単独改善のため親 Issue なし)
  • Desired Destination: なし

Current Validated Scope

  • .claude/skills/issue-refinement-loop/SKILL.md の Step 0 に「人間 Decision 検出」分岐(4分類)を追加する
  • ## Inputs に anchor_comment_url(任意)を追加する
  • LOOP_STATE の termination_reason 定義に superseded_by_decision を追加する
  • LOOP_STATE に anchor_comment: { url: null, snapshot: null } フィールドを追加する
  • superseded_by_decision 分岐の手順(issue-author ドラフト → create-issue → close → コメント記録)を明文化する
  • close は gh issue close --reason "not planned" を使うことを明記する
  • Step 5 テーブルに superseded_by_decision 行を追加する

Remaining Parent Gaps

なし

Outcome

.claude/skills/issue-refinement-loop/SKILL.md に anchor_comment_url(任意)入力と Step 0 コメント分類器(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)が追加され、LOOP_STATE.termination_reason に superseded_by_decision が追加され、superseded_by_decision 分岐では gh issue close --reason "not planned" を使って対象 Issue をクローズし、代替 Issue 番号を close コメントへ記録するコミットが存在する状態。

Background

issue-refinement-loop skill を Issue #76 に対して実行した際、対象として指定された人間コメント(https://github.com/squne121/loop-protocol/issues/76#issuecomment-4494634709)が、Issue の前提そのものを覆す Decision(「state/ready は採用しない」「Issue はクローズ」)を含んでいた。

現行の issue-refinement-loop SKILL.md は:

  • Step 0 で state/needs-human / state/done ラベルしか前提確認しない
  • 「Scope 変更シグナル検出」は iteration 中に本文へ追加された変更しか検知しない
  • 「対象 Issue / コメントに、Issue の前提を無効化する人間 Decision が既に存在する」ケースの分岐が無い

このため本来は「本文を磨いて approve」ではなく「Issue をクローズし決定方針に沿った代替 Issue を起票する」べき状況で、オーケストレーターが手順を即興で補う必要があった。この分岐を SKILL.md に明文化することで、refinement loop が前提否決済み Issue を誤って approve へ磨かないようにする。

adversarial review(issuecomment-4506900994)の5 Blockers に基づき、単純な superseded_by_decision 単一分岐から4分類コメント分類器へ再設計した。

Refs #30(Out of Scope → 実 Issue 化手順の組み込み。関連だが別スコープ), #76, #92, #127(anchor_comment_url 専用 Issue: #96 scope に取り込み済み。後で整理)

In Scope

  • .claude/skills/issue-refinement-loop/SKILL.md の ## Inputs に anchor_comment_url(任意)を追加する

  • Step 0 に「anchor_comment_url 指定時はコメント本文を gh api repos/squne121/loop-protocol/issues/comments/<id> で取得し LOOP_STATE.anchor_comment.snapshot に格納する」手順を追加する

  • Step 0 に分類器(4分類)を追加する:

    分類 条件 分岐
    superseded_by_decision 人間が明示的に「close」「前提不採用」「代替方針へ置換」と決定 close + 代替 Issue
    reframe_in_place 前提の一部は誤りだが Issue 目的は維持可能 anchor comment 内容を注入して継続
    feedback_update_required コメントが AC/VC/In Scope の追加・修正を要求 close せず本文更新
    human_escalation close か修正か判定不能 人間判断へ停止
  • superseded_by_decision 分岐の手順を以下4ステップで明記する:

    1. 対象 Issue / anchor comment / Decision 要約を取得
    2. issue-author SubAgent に「代替 Issue 本文案」を作成させる
    3. main thread が create-issue skill を実行して代替 Issue を起票
    4. 代替 Issue 番号を取得できた場合のみ gh issue close --reason "not planned" を実行し、close コメントに代替 Issue 番号と termination_reason: superseded_by_decision を記録
  • reframe_in_place / feedback_update_required: anchor comment 内容を注入して通常ループへ進む

  • human_escalation: 人間判断で停止

  • LOOP_STATE.termination_reason の定義(null | approved | max_iterations | human_escalation)に superseded_by_decision を追加する

  • LOOP_STATE に anchor_comment: { url: null, snapshot: null } フィールドを追加する

  • Step 5(終了処理)の termination_reason 対応テーブルに superseded_by_decision 行を追加する

  • close は gh issue close --reason "not planned" を使うことを明記する

Out of Scope

Acceptance Criteria

  • AC1: rg "superseded_by_decision" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(LOOP_STATE の termination_reason 定義と Step 5 テーブルの両箇所)
  • AC2: rg "人間 Decision|human.*[Dd]ecision|Decision.*シグナル" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(Step 0 の検出手順記述)
  • AC3: rg "クローズ|issue.*close|gh issue close" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(クローズアクション手順の記述)
  • AC4: rg "issue-author" .claude/skills/issue-refinement-loop/SKILL.md が Step 4 以外の箇所(Decision 分岐の委譲先記述)でもヒットする
  • AC5: rg "anchor_comment_url" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(Inputs セクション)
  • AC6: rg "feedback_update_required|reframe_in_place" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(分類器の4分類記述)
  • AC7: rg "gh issue close.*--reason.*not planned|not.planned" .claude/skills/issue-refinement-loop/SKILL.md がヒットする(close reason 明記)
  • AC8: Step 5 テーブルに superseded_by_decision 行が存在する(2件以上は従来通り)

Verification Commands

# AC1: superseded_by_decision が LOOP_STATE 定義と Step 5 テーブルの両方にある(2件以上)
rg "superseded_by_decision" .claude/skills/issue-refinement-loop/SKILL.md
test $(rg -c "superseded_by_decision" .claude/skills/issue-refinement-loop/SKILL.md) -ge 2 && echo "PASS: AC1" || echo "FAIL: AC1"

# AC2: 人間 Decision 検出手順の記述確認
rg "人間 Decision|Decision.*シグナル|decision.*signal" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC2" || echo "FAIL: AC2"

# AC3: クローズアクション手順の記述確認
rg "gh issue close|issue.*[Cc]lose|クローズ" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC3" || echo "FAIL: AC3"

# AC4: issue-author への委譲記述が Step 4 コンテキスト以外にも存在する
rg -n "issue-author" .claude/skills/issue-refinement-loop/SKILL.md

# AC5: anchor_comment_url が Inputs に存在する
rg "anchor_comment_url" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC5" || echo "FAIL: AC5"

# AC6: 分類器の4分類が記述されている
rg "feedback_update_required|reframe_in_place" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC6" || echo "FAIL: AC6"

# AC7: close reason not planned の記述確認
rg "not.planned" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC7" || echo "FAIL: AC7"

# AC8: superseded_by_decision が2箇所以上(LOOP_STATE 定義 + Step 5 テーブル)
count=$(rg -c "superseded_by_decision" .claude/skills/issue-refinement-loop/SKILL.md 2>/dev/null || echo 0)
test "$count" -ge 2 && echo "PASS: AC8 (count=$count)" || echo "FAIL: AC8 (count=$count)"

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • Decision 分岐で予定された代替 Issue 起票は In Scope。ただし、代替 Issue が 2 件以上必要・親子関係再設計が必要・または Allowed Paths 外の skill 変更が必要な場合は停止。
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Delta(任意)

adversarial review(issuecomment-4506900994)の5 Blockers に基づく再設計:

  • Blocker 1: superseded_by_decision 単一分岐 → 4分類コメント分類器(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)
  • Blocker 2: anchor_comment_url(任意)を Inputs に追加、gh api でコメント本文取得手順を追加
  • Blocker 3: Stop Conditions の「新規 Issue 起票で停止」を Decision 分岐スコープに合わせて修正
  • Blocker 4: superseded_by_decision 分岐の issue-author 委譲チェーンを4ステップで明確化
  • Blocker 5: gh issue close --reason "not planned" を In Scope に明記

Delivery Rule

  • 1 Issue = 1 PR
  • 変更対象は .claude/skills/issue-refinement-loop/SKILL.md のみ。他の skill ファイルを変更しない
  • Draft PR で開始し、AC 全項目 PASS を確認してから ready for review とする

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    on May 20, 2026
  2. squne121 commented on May 20, 2026

    @squne121
    OwnerAuthor

    具体ケース: Issue #79 が「対象コメントが Issue 前提を覆す」典型例 (2026-05-20T11:30:45Z)

    #96 の分岐が必要になる実例として記録する。

    ケース

    Issue #79 にコメント #79 (comment) が付き、ChatGPT 敵対的レビューが「#79 は retry を追加する Issue だが、create_issue_txn.py には既に retry が実装済みであり、前提が誤っている」と指摘した。これは Issue 本文の Outcome そのものを覆す内容だった。

    人間はこのコメント URL を名指しで指定して issue-refinement-loop を起動した。

    現状の skill 仕様の gap(#96 のスコープ確認)

    • issue-refinement-loop の Inputs は issue_number と max_iterations のみで、「対象コメント」を受け取る入力が存在しない。
    • 今回は Step 1 の codebase-investigator 起動時に、オーケストレーター(main thread)が手動でコメント本文を取得し、調査依頼に「コメントの主張を事実確認せよ」と織り込むことで吸収した。結果的に再フレームは成功したが、これは skill 化された手順ではなく即興対応。
    • コメントが Issue 前提を覆す場合、本来は「needs-fix で本文改善ループに入る」前に「前提覆しの事実確認 → 再フレーム要否判定」という分岐があるべき、という 改善: issue-refinement-loop に「対象コメントが Issue 前提を覆す人間 Decision を含む場合」の分岐を追加する #96 の問題意識を実地で裏付けた。

    設計上の追加示唆

    • issue-refinement-loop の Inputs に任意 anchor_comment_url を追加し、指定時は Step 1 の調査依頼へ「コメントの主張の事実確認」を必須注入する案。
    • 事実確認の結果コメントが Issue 前提を覆すと判明したら、ループ内で扱える「本文再フレーム」と、人間判断が要る「scope 変更」を区別する判定が要る(後者は既存の Scope 変更シグナル検出に接続できる)。

    (出典: Issue #79 issue-refinement-loop, 2026-05-20)

  3. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    関連ケースの実例報告: adversarial review による新規要件追加パターン

    Issue #92 の refinement-loop(2026-05-21)で、本 Issue が扱う「Issue 前提を覆す Decision」とは異なる関連パターンを観測しました。

    観測したパターン

    状況: Issue #92 は 2026-05-20 に review-issue: approve 済み。翌日(2026-05-21)に人間がコメント群を追加し、最終的に詳細な adversarial review(issuecomment-4504529093)で「No-Go as-is / Revise before implementation」を明記した。

    問題: C1-C8 の決定論的チェックは全て pass(前回 approve から本文が変わっていないため)。review-issue が単体で動いた場合、そのまま approve を返し、コメントに含まれる新要件(AC6/AC7/AC8)が取り込まれないまま終了していた可能性がある。

    今回の対処: issue-refinement-loop のオーケストレーター層で、「コメントに adversarial review や新要件が含まれる場合は needs-fix として扱う」判断を行い、issue-author で本文を更新した。

    本 Issue との違い

    #96 が扱う 今回のパターン
    Issue の前提を覆す人間 Decision Issue を生かしたまま新要件を追加する adversarial review
    対応: close + 代替 Issue 起票 対応: 本文に AC/VC を追加して継続

    提案

    Issue #96 のスコープに以下を含めるか、別 Issue として切り出すかを検討してください:

    追加分岐案: コメントが「新要件の追加(AC/VC/In Scope 変更)を要求しているが本文に未反映」のパターンを検出する

    具体的な検出ロジック:

    • コメントに No-Go as-is / Revise before implementation / AC[N] 追加 等の明示的フラグが含まれる
    • または: コメントに ## Acceptance Criteria / ## In Scope への追記提案が含まれる

    この場合の分岐:

    • close はしない(Issue 自体は有効)
    • コメントを reviewer_feedback_text として issue-author に渡し本文を更新する
    • review-issue を再実行する

    Refs #92(実例)

  4. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    一から書き直す方が良いのか、それともIssueを修整したほうがいいのか。
    それは人間方針の転換度合いに寄りそうだけど、必ず新たに書き起こす運用が適切なのか、不明。
    人間指摘

  5. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-21T09:41:02Z)

    • iteration: 1
    • verdict: approve
    • termination_reason: approved
    • 改善履歴: 本文改善なし(初回レビューで approve)
    • 次アクション: issue-contract-review 起動可

    チェック結果

    チェック 結果
    C1: 必須セクション PASS
    C2: Stop Conditions ≥6 PASS
    C3: AC checkbox 形式 PASS
    C4: VC コマンド存在 PASS
    C5: AC ⇔ VC 番号整合 PASS
    C6: 主観表現なし PASS
    C7: Required Skills 意味論 PASS
    C8: Outcome 具体性 PASS

    Non-blocking 観察事項

    1. コメント(「一から書き直す方が良いのか…」)が「前提否決時は必ず Close + 新規起票」という設計前提に疑問を呈しています。設計判断として実装時に考慮してください。
    2. Issue 実装: create_issue_txn.py の sub-issue-readback retry 固定 + implementation Issue 標準ラベル自動付与(#61 統合) #79 コメントが anchor_comment_url 入力追加案を提示しています(Out of Scope として記録)。
  6. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    総評: No-Go as-is / Issue #96 は実装前に再設計が必要

    Issue #96 の問題意識は正しいです。現行 issue-refinement-loop は Step 0 で state/needs-human / state/done しか見ておらず、既存コメントに「Issue 前提を無効化する人間 Decision」がある場合の分岐がありません。現在の SKILL.md でも termination_reason は null | approved | max_iterations | human_escalation のみで、superseded_by_decision は未定義です。

    ただし、Issue #96 の現在案は #76 の成功事例に過剰適合しています。「人間 Decision 検出 → 必ず close + 代替 Issue 起票」という単線化は危険です。#96 自身のコメントでも「一から書き直すべきか、Issue を修整すべきかは人間方針の転換度合いに依存しそう」と指摘されています。


    致命的なレビュー指摘

    1. close + 代替 Issue 起票 を固定分岐にしているのが過剰

    #76 は確かに close + 代替 Issue 起票が妥当でした。人間コメントで state/ready 不採用、AI 着手可能性の source of truth は blocker/dependency 解消状態とする、さらに「Issue はクローズ」と明示されていました。

    しかし #92 の実例は別です。#92 は Issue 自体は有効なまま、後続の adversarial review コメントで AC6/AC7/AC8 相当の新要件が追加されたケースです。#96 のコメントでも、この場合は close せず、コメントを reviewer_feedback_text として issue-author に渡し、本文更新後に review-issue を再実行する分岐が提案されています。

    修正方針:
    superseded_by_decision だけでなく、最低限次の分類を Step 0 に入れるべきです。

    分類 | 条件 | 分岐 -- | -- | -- superseded_by_decision | 人間が明示的に「この Issue は close」「前提不採用」「代替方針へ置換」と決定 | close + 代替 Issue reframe_in_place | 前提の一部は誤りだが、Issue 目的は維持可能 | 本文を再フレームして継続 feedback_update_required | コメントが AC/VC/In Scope の追加・修正を要求 | close せず本文更新 human_escalation | close か修正か判定不能 | 人間判断へ停止

    現状の #96 はこの分類が無いため、実装すると「修正で済む Issue まで捨てて作り直す」運用になり得ます。


    2. anchor_comment_url が入力契約に無いまま「指定コメント」を扱おうとしている

    現行 issue-refinement-loop の Inputs は issue_number と max_iterations だけです。
    #96 コメントでも、#79 の実例から「対象コメントを受け取る入力が存在しない」ことが gap として記録されています。

    Claude Code の subagent は独立した context window で動き、親会話の履歴や既読ファイルを自動では見ません。必要な情報は delegation message / 入力として渡す必要があります。(Claude API Docs)

    修正方針:
    #96 の In Scope に以下を追加すべきです。

    inputs:
      issue_number: <int>
      max_iterations: <int, default 3>
      anchor_comment_url: <optional string>
    

    さらに Step 0 で:

    gh issue view <issue_number> --json title,body,comments,labels,state,stateReason
    

    または指定コメント URL がある場合:

    gh api repos/squne121/loop-protocol/issues/comments/<comment_id>
    

    のように、対象コメント本文を明示取得する手順が必要です。


    3. Stop Conditions と In Scope が矛盾している

    #96 の In Scope は「Issue クローズコマンド + issue-author SubAgent への代替 Issue 起票委譲手順」を含みます。一方、Stop Conditions には「新規 Issue の起票が必要と判断した場合は停止」とあります。

    これは実装契約として矛盾しています。

    修正案:

    Stop Conditions を次のように分けるべきです。

    - Decision 分岐で予定された代替 Issue 起票は In Scope。
    - ただし、代替 Issue が 2 件以上必要、親子関係再設計が必要、または Allowed Paths 外の skill 変更が必要な場合は停止。
    

    4. issue-author への「代替 Issue 起票委譲」が責務境界として曖昧

    Claude Code 公式 docs では、subagent は task-specific worker として独立 context / tool access / permissions を持つ設計です。さらに subagent は他の subagent を spawn できないため、nested delegation が必要な workflow は main conversation 側で chain するか skill として扱うべきです。(Claude API Docs)

    #96 は「issue-author SubAgent への代替 Issue 起票委譲」と書いていますが、実際には issue-author が create-issue skill を使うのか、main thread が issue-author に本文 draft だけ作らせて create-issue を実行するのかが不明です。

    修正方針:
    issue-refinement-loop は control-plane として、以下のように明記するのが安全です。

    Decision 分岐では main thread が orchestration する:
    1. 対象 Issue / anchor comment / Decision 要約を取得
    2. issue-author SubAgent に「代替 Issue 本文案」を作成させる
    3. main thread が create-issue skill を実行して代替 Issue を起票
    4. 代替 Issue 番号を取得できた場合のみ gh issue close を実行
    5. close コメントに代替 Issue 番号と termination_reason を記録
    

    これなら nested SubAgent delegation を避けられます。


    5. close 操作の reason が未定義

    GitHub CLI の gh issue close は --reason として completed | not planned | duplicate を受け取ります。(GitHub CLI)
    GitHub REST API でも state_reason は completed, not_planned, duplicate, reopened, null が定義されています。(GitHub Docs)

    #76 のような「人間 Decision により旧 Issue を置換する」ケースは、完了ではなく not planned が自然です。#76 も実際に state_reason: not_planned で closed されています。

    AC に追加すべき内容:

    rg -n "gh issue close.*--reason.*not planned|state_reason.*not_planned" .claude/skills/issue-refinement-loop/SKILL.md
    

    関連 Issue / PR から見た設計上の位置づけ

    #96 は #30 と重なりそうで、実際には別問題です。#30 は Out of Scope / Remaining Parent Gaps の defer 提案を実 Issue 化する導線の問題です。
    #96 は「既存 Issue の前提が人間 Decision で否定された場合の loop 分岐」です。したがって #30 を取り込むべきではありませんが、代替 Issue 起票時に follow-up / defer 起票ルールと衝突しないことは明記すべきです。

    PR #102 で web-researcher が issue-refinement-loop に組み込まれ、外部仕様・公式 docs・公開 API の事実確認を Step 1b として扱う設計になっています。#96 実装時は、この Step 1b と Decision 分岐の順序を整理する必要があります。

    推奨順序は:

    Step 0a: Issue / anchor comment 取得
    Step 0b: 人間 Decision / reviewer feedback / scope-change signal 分類
    Step 0c: 分類に必要な critical claim が外部仕様依存なら web-researcher
    Step 0d: 分岐確定
    

    具体的な高品質化パッチ方針

    最小修正ではなく、Issue #96 本文を修正してから実装するべき

    現状の #96 をそのまま実装すると、superseded_by_decision という termination_reason は追加されますが、運用判断の精度が低くなります。特に #92 型の「新要件追加」コメントを誤って close 対象に分類するリスクがあります。

    修正後の Outcome 案

    `.claude/skills/issue-refinement-loop/SKILL.md` に Step 0 として
    `anchor_comment_url` を含む対象 Issue / コメント取得、コメント分類、
    および分類別分岐が記載されている状態。
    

    分類は少なくとも以下を含む:

    • superseded_by_decision: Issue 前提が人間 Decision により無効化され、close + 代替 Issue が必要
    • feedback_update_required: Issue は有効だが、コメントの新要件・adversarial review を本文へ反映すべき
    • reframe_in_place: Issue 目的は維持しつつ、誤った前提を本文内で再フレームすべき
    • human_escalation: 判定不能

    LOOP_STATE.termination_reason に superseded_by_decision を追加し、
    close 時は gh issue close --reason "not planned" を使い、
    代替 Issue 番号を close コメントへ記録する。

    追加すべき Acceptance Criteria

    # anchor_comment_url 入力契約
    rg -n "anchor_comment_url" .claude/skills/issue-refinement-loop/SKILL.md

    分類が単線 close ではないこと

    rg -n "feedback_update_required|reframe_in_place|superseded_by_decision|human_escalation" .claude/skills/issue-refinement-loop/SKILL.md

    close reason が not planned

    rg -n "gh issue close.*--reason.*not planned|not_planned" .claude/skills/issue-refinement-loop/SKILL.md

    代替 Issue 起票前に close しない順序

    rg -n "代替 Issue.*起票.*成功.*gh issue close|close.*代替 Issue 番号" .claude/skills/issue-refinement-loop/SKILL.md

    #92 型の「Issue は有効だがコメント反映が必要」ケースを明文化

    rg -n "No-Go as-is|Revise before implementation|reviewer_feedback_text|AC.*追加" .claude/skills/issue-refinement-loop/SKILL.md


    推奨判定

    このまま実装: 非推奨。
    Issue #96 を修正してから実装: 推奨。

    優先修正はこの順です。

    1. anchor_comment_url を入力契約に追加

    2. 「Decision 検出」を close 固定 ではなく 分類器 として定義

    3. Stop Conditions の「新規 Issue 起票で停止」と In Scope の矛盾を解消

    4. close reason を not planned に固定

    5. 実装: state ラベル意味論の明確化と blocker/dependency ベース着手可能判定の SSOT 化 (A2 再定義) #92 型の feedback_update_required 分岐を In Scope に入れるか、別 Issue として切る

    6. AC を grep だけでなく、誤分類防止の観点に寄せる

    結論として、#96 は「前提否決済み Issue を approve へ磨かない」ために必要ですが、現状は “否決済み” と “修正要求あり” を同一視しているのが最大の欠陥です。

    ## 総評: **No-Go as-is / Issue #96 は実装前に再設計が必要**

    Issue #96 の問題意識は正しいです。現行 issue-refinement-loop は Step 0 で state/needs-human / state/done しか見ておらず、既存コメントに「Issue 前提を無効化する人間 Decision」がある場合の分岐がありません。現在の SKILL.md でも termination_reason は null | approved | max_iterations | human_escalation のみで、superseded_by_decision は未定義です。

    ただし、Issue #96 の現在案は #76 の成功事例に過剰適合しています。「人間 Decision 検出 → 必ず close + 代替 Issue 起票」という単線化は危険です。#96 自身のコメントでも「一から書き直すべきか、Issue を修整すべきかは人間方針の転換度合いに依存しそう」と指摘されています。


    致命的なレビュー指摘

    1. close + 代替 Issue 起票 を固定分岐にしているのが過剰

    #76 は確かに close + 代替 Issue 起票が妥当でした。人間コメントで state/ready 不採用、AI 着手可能性の source of truth は blocker/dependency 解消状態とする、さらに「Issue はクローズ」と明示されていました。

    しかし #92 の実例は別です。#92 は Issue 自体は有効なまま、後続の adversarial review コメントで AC6/AC7/AC8 相当の新要件が追加されたケースです。#96 のコメントでも、この場合は close せず、コメントを reviewer_feedback_text として issue-author に渡し、本文更新後に review-issue を再実行する分岐が提案されています。

    修正方針:
    superseded_by_decision だけでなく、最低限次の分類を Step 0 に入れるべきです。

    分類 条件 分岐
    superseded_by_decision 人間が明示的に「この Issue は close」「前提不採用」「代替方針へ置換」と決定 close + 代替 Issue
    reframe_in_place 前提の一部は誤りだが、Issue 目的は維持可能 本文を再フレームして継続
    feedback_update_required コメントが AC/VC/In Scope の追加・修正を要求 close せず本文更新
    human_escalation close か修正か判定不能 人間判断へ停止

    現状の #96 はこの分類が無いため、実装すると「修正で済む Issue まで捨てて作り直す」運用になり得ます。


    2. anchor_comment_url が入力契約に無いまま「指定コメント」を扱おうとしている

    現行 issue-refinement-loop の Inputs は issue_number と max_iterations だけです。
    #96 コメントでも、#79 の実例から「対象コメントを受け取る入力が存在しない」ことが gap として記録されています。

    Claude Code の subagent は独立した context window で動き、親会話の履歴や既読ファイルを自動では見ません。必要な情報は delegation message / 入力として渡す必要があります。([Claude API Docs]1)

    修正方針:
    #96 の In Scope に以下を追加すべきです。

    inputs:
      issue_number: <int>
      max_iterations: <int, default 3>
      anchor_comment_url: <optional string>

    さらに Step 0 で:

    gh issue view <issue_number> --json title,body,comments,labels,state,stateReason

    または指定コメント URL がある場合:

    gh api repos/squne121/loop-protocol/issues/comments/<comment_id>

    のように、対象コメント本文を明示取得する手順が必要です。


    3. Stop Conditions と In Scope が矛盾している

    #96 の In Scope は「Issue クローズコマンド + issue-author SubAgent への代替 Issue 起票委譲手順」を含みます。一方、Stop Conditions には「新規 Issue の起票が必要と判断した場合は停止」とあります。

    これは実装契約として矛盾しています。

    修正案:

    Stop Conditions を次のように分けるべきです。

    - Decision 分岐で予定された代替 Issue 起票は In Scope。
    - ただし、代替 Issue が 2 件以上必要、親子関係再設計が必要、または Allowed Paths 外の skill 変更が必要な場合は停止。

    4. issue-author への「代替 Issue 起票委譲」が責務境界として曖昧

    Claude Code 公式 docs では、subagent は task-specific worker として独立 context / tool access / permissions を持つ設計です。さらに subagent は他の subagent を spawn できないため、nested delegation が必要な workflow は main conversation 側で chain するか skill として扱うべきです。([Claude API Docs]1)

    #96 は「issue-author SubAgent への代替 Issue 起票委譲」と書いていますが、実際には issue-author が create-issue skill を使うのか、main thread が issue-author に本文 draft だけ作らせて create-issue を実行するのかが不明です。

    修正方針:
    issue-refinement-loop は control-plane として、以下のように明記するのが安全です。

    Decision 分岐では main thread が orchestration する:
    1. 対象 Issue / anchor comment / Decision 要約を取得
    2. issue-author SubAgent に「代替 Issue 本文案」を作成させる
    3. main thread が create-issue skill を実行して代替 Issue を起票
    4. 代替 Issue 番号を取得できた場合のみ gh issue close を実行
    5. close コメントに代替 Issue 番号と termination_reason を記録

    これなら nested SubAgent delegation を避けられます。


    5. close 操作の reason が未定義

    GitHub CLI の gh issue close は --reason として completed | not planned | duplicate を受け取ります。([GitHub CLI]2)
    GitHub REST API でも state_reason は completed, not_planned, duplicate, reopened, null が定義されています。([GitHub Docs]3)

    #76 のような「人間 Decision により旧 Issue を置換する」ケースは、完了ではなく not planned が自然です。#76 も実際に state_reason: not_planned で closed されています。

    AC に追加すべき内容:

    rg -n "gh issue close.*--reason.*not planned|state_reason.*not_planned" .claude/skills/issue-refinement-loop/SKILL.md

    関連 Issue / PR から見た設計上の位置づけ

    #96 は #30 と重なりそうで、実際には別問題です。#30 は Out of Scope / Remaining Parent Gaps の defer 提案を実 Issue 化する導線の問題です。
    #96 は「既存 Issue の前提が人間 Decision で否定された場合の loop 分岐」です。したがって #30 を取り込むべきではありませんが、代替 Issue 起票時に follow-up / defer 起票ルールと衝突しないことは明記すべきです。

    PR #102 で web-researcher が issue-refinement-loop に組み込まれ、外部仕様・公式 docs・公開 API の事実確認を Step 1b として扱う設計になっています。#96 実装時は、この Step 1b と Decision 分岐の順序を整理する必要があります。

    推奨順序は:

    Step 0a: Issue / anchor comment 取得
    Step 0b: 人間 Decision / reviewer feedback / scope-change signal 分類
    Step 0c: 分類に必要な critical claim が外部仕様依存なら web-researcher
    Step 0d: 分岐確定
    

    具体的な高品質化パッチ方針

    最小修正ではなく、Issue #96 本文を修正してから実装するべき

    現状の #96 をそのまま実装すると、superseded_by_decision という termination_reason は追加されますが、運用判断の精度が低くなります。特に #92 型の「新要件追加」コメントを誤って close 対象に分類するリスクがあります。

    修正後の Outcome 案

    `.claude/skills/issue-refinement-loop/SKILL.md` に Step 0 として
    `anchor_comment_url` を含む対象 Issue / コメント取得、コメント分類、
    および分類別分岐が記載されている状態。
    
    分類は少なくとも以下を含む:
    - `superseded_by_decision`: Issue 前提が人間 Decision により無効化され、close + 代替 Issue が必要
    - `feedback_update_required`: Issue は有効だが、コメントの新要件・adversarial review を本文へ反映すべき
    - `reframe_in_place`: Issue 目的は維持しつつ、誤った前提を本文内で再フレームすべき
    - `human_escalation`: 判定不能
    
    `LOOP_STATE.termination_reason` に `superseded_by_decision` を追加し、
    close 時は `gh issue close --reason "not planned"` を使い、
    代替 Issue 番号を close コメントへ記録する。

    追加すべき Acceptance Criteria

    # anchor_comment_url 入力契約
    rg -n "anchor_comment_url" .claude/skills/issue-refinement-loop/SKILL.md
    
    # 分類が単線 close ではないこと
    rg -n "feedback_update_required|reframe_in_place|superseded_by_decision|human_escalation" .claude/skills/issue-refinement-loop/SKILL.md
    
    # close reason が not planned
    rg -n "gh issue close.*--reason.*not planned|not_planned" .claude/skills/issue-refinement-loop/SKILL.md
    
    # 代替 Issue 起票前に close しない順序
    rg -n "代替 Issue.*起票.*成功.*gh issue close|close.*代替 Issue 番号" .claude/skills/issue-refinement-loop/SKILL.md
    
    # #92 型の「Issue は有効だがコメント反映が必要」ケースを明文化
    rg -n "No-Go as-is|Revise before implementation|reviewer_feedback_text|AC.*追加" .claude/skills/issue-refinement-loop/SKILL.md

    推奨判定

    このまま実装: 非推奨。
    Issue #96 を修正してから実装: 推奨。

    優先修正はこの順です。

    1. anchor_comment_url を入力契約に追加
    2. 「Decision 検出」を close 固定 ではなく 分類器 として定義
    3. Stop Conditions の「新規 Issue 起票で停止」と In Scope の矛盾を解消
    4. close reason を not planned に固定
    5. 実装: state ラベル意味論の明確化と blocker/dependency ベース着手可能判定の SSOT 化 (A2 再定義) #92 型の feedback_update_required 分岐を In Scope に入れるか、別 Issue として切る
    6. AC を grep だけでなく、誤分類防止の観点に寄せる

    結論として、#96 は「前提否決済み Issue を approve へ磨かない」ために必要ですが、現状は “否決済み” と “修正要求あり” を同一視しているのが最大の欠陥です。

  7. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    issuecomment-4506900994 の adversarial review(5 Blockers)に基づく再設計により Issue 本文を更新した。

    変更内容

    • Blocker 1: superseded_by_decision 単一分岐 → 4分類コメント分類器(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)を Step 0 に追加
    • Blocker 2: anchor_comment_url(任意)を ## Inputs に追加、gh api でコメント本文取得手順と LOOP_STATE.anchor_comment.snapshot 格納手順を明記
    • Blocker 3: Stop Conditions の「新規 Issue 起票が必要な場合は停止」を Decision 分岐スコープに合わせて修正(予定された代替 Issue 1件は In Scope)
    • Blocker 4: superseded_by_decision 分岐の issue-author 委譲チェーンを4ステップ(ドラフト → create-issue → close → コメント記録)で明確化
    • Blocker 5: gh issue close --reason "not planned" を In Scope に明記

    追加された AC

    • AC5: anchor_comment_url が Inputs セクションに存在する
    • AC6: 分類器の4分類(feedback_update_required / reframe_in_place)が記述されている
    • AC7: close reason not planned の記述が確認できる
    • AC8: Step 5 テーブルに superseded_by_decision 行が存在する(2件以上)

    Note: Issue #127(anchor_comment_url 専用)は #96 scope に取り込み済み。後で整理する。

  8. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了(再実行)(2026-05-21T09:54:09Z)

    • iteration: 2(adversarial review によって needs-fix → 再設計 → approve)
    • verdict: approve
    • termination_reason: approved
    • 改善履歴:
      • iteration 0: C1-C8 PASS → approve(ただし設計レベル issues を見逃し)
      • iteration 1: issuecomment-4506900994 adversarial review(5 Blockers)→ 本文再設計
        • B1: close 固定分岐 → 4分類分類器(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)
        • B2: anchor_comment_url を Inputs に追加
        • B3: Stop Conditions と In Scope の矛盾を解消
        • B4: issue-author 委譲チェーン(4ステップ)を明記
        • B5: gh issue close --reason "not planned" を明記
      • iteration 2: re-review → approve
    • 次アクション: issue-contract-review 起動可(Issue 実装: issue-refinement-loop に ANCHOR_COMMENT_CONTEXT_V1 / ANCHOR_COMMENT_FACT_CHECK_RESULT_V1 / requires_fact_check を追加し anchor comment fact-check の入出力契約を固定する #127 の scope 重複は整理済み)
  9. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-21T10:00:17Z)

    • Outcome: .claude/skills/issue-refinement-loop/SKILL.md に anchor_comment_url(任意)入力と Step 0 コメント分類器(superseded_by_decision / reframe_in_place / feedback_update_required / human_escalation)が追加され、LOOP_STATE.termination_reason に superseded_by_decision が追加され、superseded_by_decision 分岐では gh issue close --reason "not planned" を使って対象 Issue をクローズし、代替 Issue 番号を close コメントへ記録するコミットが存在する状態。
    • Acceptance Criteria: AC1〜AC8(8件)
    • Verification Commands: AC1〜AC8 対応 rg/test コマンド
    • Allowed Paths: .claude/skills/issue-refinement-loop/SKILL.md
    • Worktree: .claude/worktrees/issue-96-issue-refinement-loop-human-decision-bra
    • Branch: worktree-issue-96-issue-refinement-loop-human-decision-bra
    • VC preflight: baseline fail = 7, 想定外 pass = 0, 実行不可 = 0
    • Warning: AC4 VC は listing コマンド(assertion なし)。実装者が Step 4 以外の issue-author 記述を手動確認すること。
  10. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-21T10:05:28Z)

  11. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-21T10:08:59Z)

    実装内容

    変更 詳細
    Inputs 追加 anchor_comment_url(任意)
    LOOP_STATE 追加 anchor_comment: { url, snapshot }、superseded_by_decision
    Step 0a anchor_comment_url 指定時の gh api コメント取得手順
    Step 0b 4分類コメント分類器テーブル
    Step 0c superseded_by_decision 分岐(issue-author → create-issue → gh issue close --reason "not planned" → close コメント)
    Step 5 superseded_by_decision 行追加

    検証結果

    • AC1〜AC8: 全 PASS
    • pnpm typecheck / lint / test / build: 全 PASS
    • pytest: 21/21 PASS

    次アクション

    PR #128 を人間がレビュー・マージしてください。マージ後は post-merge-cleanup を実行してください。

  12. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-21T10:25:35Z)

    イテレーション履歴

    iteration verdict 対応内容
    0 REQUEST_CHANGES 初回実装 → 8 Blockers 指摘(事実確認前分類・入力契約未定義・スキーマ不足・issue 所属検証なし・close 2コマンド問題・非冪等・出力契約なし・stale approval 処理)
    1 APPROVE B1〜B8 全修正(preliminary classification 2段階化・LOOP_STATE 拡張・Idempotency preflight・ALTERNATIVE_ISSUE_DRAFT_V1 契約・統合 close コマンド等)

    最終検証

    • AC1〜AC8: 全 PASS
    • B3〜B7 拡張 VC: 全 PASS
    • pnpm typecheck / lint / test / build: 全 PASS
    • pytest: 21/21 PASS

    次アクション

    PR #128 を人間がレビュー・マージしてください。マージ後は post-merge-cleanup を実行してください。

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

    enhancementphase/implementationstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions