Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "issue-refinement-loop と impl-review-loop の implementation-ready handoff を contract gate 化し、refinement approved と implementation-ready を別状態として厳密に区別する"
change_kind: mixedParent Issue
なし(スタンドアロン Issue)
Parent Goal Ref
- Goal:
issue-refinement-loopのtermination_reason: approvedがimpl-review-loopの preparation で "implementation-ready" と誤認される handoff gap を解消する - Desired Destination:
CONTRACT_REVIEW_RESULT_V1 status: goの存在・鮮度チェックがimpl-review-looppreparation の intake gate として機能し、gap が確定論的に検出される状態
Current Validated Scope
issue-refinement-loopの終了状態をrefinement_approved_gate_pendingとimplementation_readyに分けるissue-contract-reviewのCONTRACT_REVIEW_RESULT_V1 status: goをimpl-review-loopの必須入力として明文化する(ドキュメントまたはスクリプト修正)impl-review-looppreparation でintake_gate_failedを独立したtermination_reasonとして扱う(missing_contract_go/metadata_not_ready/stale_contract_review/body_snapshot_mismatchのサブ理由付き)- body_sha256 / comment freshness チェックを preparation の intake gate に追加する
- 実装: WSL2/Ubuntu human playtest 実行環境 runbook と preflight を追加する #561 相当の regression fixture を追加する
Remaining Parent Gaps
本 Issue スコープ外として残存:
issue-contract-reviewskill の gate-only / idempotent mode の execution-level 実装- title prefix 自動付与・
phase/implementationlabel 自動更新のロジック(現在は手動/ヒューリスティック) impl-review-loopの preparation 以降フローへの影響調査(intake_gate_failed 後の human escalation 動線)
背景
issue-refinement-loop が issue-reviewer approve で終了すると、impl-review-loop が "implementation-ready" と誤認する handoff gap が存在する。
具体的には:
issue-refinement-loopの終了(termination_reason: approved)は「本文の refinement が完了した」意味だが、「implementation-ready gate を通過した」意味ではないimpl-review-loopの preparation はCONTRACT_REVIEW_RESULT_V1 status: goコメントを必須としているが、refinement loop はこれを生成しない- Issue の title prefix(
実装:/implement:)とphase/implementationlabel の更新も refinement loop では行われない - 古い
status: goコメント(body_sha256 が現在の Issue 本文と一致しないもの)を誤採用するリスクもある
この gap により、refinement が完了した Issue でも impl-review-loop が preparation で停止し、人間が手動で metadata 更新と issue-contract-review 実行を行う必要が生じる(#561 で再現)。
設計方針:
issue-refinement-loop(本文改善のみ)
→ issue-contract-review(CONTRACT_REVIEW_RESULT_V1 status: go 生成 + title/label 更新)
→ impl-review-loop(go snapshot のみを実装対象とする)
control-plane が作業内容や gate 判断を抱えず、worker / deterministic checker 側に責務を寄せる。
設計決定: fail-only gate
impl-review-loop は CONTRACT_REVIEW_RESULT_V1 status: go コメントが存在しない場合に issue-contract-review を自動実行しない。最新の valid go コメントがなければ intake_gate_failed: missing_contract_go で停止する(fail-only gate)。gate 判定と成果物生成を同一 loop で混在させない。
Outcome
以下のファイルが更新・追加され、pnpm test および pnpm build が PASS した状態でコミットされている:
- 終了状態分離:
issue-refinement-loopの termination 定義(SKILL.md または references/termination-policy.md)にrefinement_approved_gate_pending(issue-contract-review 未実行)とimplementation_ready(go comment 確認済み)の 2 状態が明文化される - intake gate 明文化:
impl-review-looppreparation(SKILL.md または steps/preparation.md)にCONTRACT_REVIEW_RESULT_V1 status: goが必須入力として記述され、欠ける場合のtermination_reason: intake_gate_failedと 4 つのサブ理由(missing_contract_go/metadata_not_ready/stale_contract_review/body_snapshot_mismatch)が定義される - freshness チェック: body_sha256 と comment freshness(
status: goより後のREQUEST_CHANGES無効化)ルールが preparation gate に追記される - regression fixture: 実装: WSL2/Ubuntu human playtest 実行環境 runbook と preflight を追加する #561 型(refinement approved だが go comment / metadata がない状態)の fixture またはテストが追加される
Note: 具体的な変更対象ファイルパスは実装前調査で確定する(Allowed Paths 参照)。
In Scope
issue-refinement-loopSKILL.md または references/termination-policy.md への終了状態分離定義の追記impl-review-loopSKILL.md または steps/preparation.md への intake gate 必須入力・intake_gate_failedtermination 定義の追記- preparation intake gate への body_sha256 freshness チェックルール追記
- preparation intake gate への「
status: goより後のREQUEST_CHANGESコメントは go を無効化する」ルール追記 - 実装: WSL2/Ubuntu human playtest 実行環境 runbook と preflight を追加する #561 型の regression fixture または integration test の追加
- title prefix(
実装:/implement:)とphase/implementationlabel の欠如チェックを intake gate に追加
Out of Scope
issue-contract-reviewskill のロジック変更issue-refinement-loopの VC / AC ルール変更(実装: issue-refinement-loop の完了条件に issue-contract-review gate を追加し VC 差分性違反を refinement 中に検出する #560 のスコープ)impl-review-looppreparation 以降フロー(implementation 実行・PR 作成)の変更- 既存 Issue の本文・metadata 修正
- 新規 label・title prefix の自動付与ロジック実装(runner-side の自動化)
Acceptance Criteria
- AC1:
issue-refinement-loopの定義にrefinement_approved_gate_pending状態が追加され、issue-reviewer approveだけではimplementation_readyを返さないことが明文化されている - AC2:
impl-review-looppreparation の定義にCONTRACT_REVIEW_RESULT_V1 status: goが必須入力として明記され、欠ける場合のtermination_reason: intake_gate_failedが定義されている。failure subreason の優先順位(metadata_not_ready>missing_contract_go>stale_contract_review>body_snapshot_mismatch>request_changes_after_go)が明記されている - AC3: title prefix(
実装:/implement:)またはphase/implementationlabel が欠ける Issue はintake_gate_failedになることが定義されている - AC4:
goコメントの freshness チェックが preparation gate に定義されている。body_sha256フィールドが存在する場合は hash 比較で検証、存在しない場合はgenerated_at < issue.updated_atをstale_contract_reviewとするフォールバックを使用することが明記されている - AC5:
go無効化 marker が machine-readable block として定義されている(free textREQUEST_CHANGES検出を避ける)。少なくともsource: issue_comment、accepted_marker: fenced_yaml REVIEW_RESULT_V1.status == request_changes、target_issue_url_must_match: true、ordering_key: created_atが定義されており、最新goより後の valid marker がgoを無効化することが preparation gate に定義されている - AC6: 実装: WSL2/Ubuntu human playtest 実行環境 runbook と preflight を追加する #561 型の fixture(refinement approved だが go comment / metadata がない状態)で regression テストまたは検証手順が追加されている
- AC7:
pnpm testが PASS する(回帰なし) - AC8:
pnpm buildが PASS する(回帰なし)
Verification Commands
# AC1
# preflight-scope: pr_review_only
$ rg -rn 'refinement_approved_gate_pending' .claude/skills/issue-refinement-loop/
# AC2
# preflight-scope: pr_review_only
$ rg -rn 'intake_gate_failed' .claude/skills/impl-review-loop/
# AC2
# preflight-scope: pr_review_only
$ rg -rn 'CONTRACT_REVIEW_RESULT_V1.*go\|status.*go.*required\|必須入力' .claude/skills/impl-review-loop/
# AC3
# preflight-scope: pr_review_only
$ rg -rn 'metadata_not_ready\|phase/implementation.*label\|title.*prefix' .claude/skills/impl-review-loop/
# AC4
# preflight-scope: pr_review_only
$ rg -rn 'body_sha256\|body_snapshot_mismatch\|stale_contract_review' .claude/skills/impl-review-loop/
# AC5
# preflight-scope: pr_review_only
$ rg -rn 'REQUEST_CHANGES\|missing_contract_go\|go.*無効' .claude/skills/impl-review-loop/
# AC6
# preflight-scope: pr_review_only
$ rg -rn '561\|refinement_approved_gate_pending\|go.*comment.*missing' .claude/skills/impl-review-loop/tests/
# AC7
# preflight-scope: runtime_only
$ pnpm test
# AC8
# preflight-scope: runtime_only
$ pnpm buildAllowed Paths
実装前調査で確定する。暫定候補:
.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/references/termination-policy.md(存在する場合).claude/skills/impl-review-loop/SKILL.md.claude/skills/impl-review-loop/steps/preparation.md.claude/skills/impl-review-loop/tests/(regression fixture 追加先)
実装開始前に ls .claude/skills/issue-refinement-loop/ および ls .claude/skills/impl-review-loop/ を実行して実際のファイル構成を確認し、Allowed Paths を確定する。
Stop Conditions
実装中にこれらの状況が発生したら直ちに作業を停止し、Issue comment に状況を記録して人間の判断を待つ。
- Allowed Paths 外の変更が必要と判明した場合
issue-contract-reviewskill のロジック変更が必要と判明した場合(Out of Scope)impl-review-looppreparation 以降フローへの影響が判明した場合- In Scope の固定契約の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合
- 実装: issue-refinement-loop の完了条件に issue-contract-review gate を追加し VC 差分性違反を refinement 中に検出する #560/docs(#560): establish final gate, VC diff rules, preflight-scope per-command, stale-result invalidation #563 の実装と重複・競合する変更が必要と判明した場合(Out of Scope の producer-side 変更への越境)
Runtime Verification Applicability
- decision: not_applicable
- reason: 変更対象は skill SKILL.md / references Markdown ファイル + regression fixture(テストファイル)。
pnpm testで回帰確認が完結し、プロセス起動・ネットワーク通信・外部サービス依存はない。
Required Skills
なし
Delivery Rule
1 Issue = 1 PR- worktree:
.claude/worktrees/issue-<N>-handoff-contract-gate - Draft PR 既定
関連 Issue
- 実装: WSL2/Ubuntu human playtest 実行環境 runbook と preflight を追加する #561: この gap が実際に発生した Issue(refinement approved だが impl-review-loop が停止)
- 実装: issue-refinement-loop の完了条件に issue-contract-review gate を追加し VC 差分性違反を refinement 中に検出する #560/docs(#560): establish final gate, VC diff rules, preflight-scope per-command, stale-result invalidation #563(MERGED):
issue-refinement-loop終了条件へのissue-contract-reviewgate 追加(producer-side。実装: issue-refinement-loop と impl-review-loop の implementation-ready handoff を contract gate 化する #564 は consumer-side のimpl-review-loopintake gate に限定)
Source
dedupe_key: "workflow:impl-review-loop:implementation-ready-handoff-contract-gate"
source:
kind: post_impl_loop_failure
origin_issue: "https://github.com/squne121/loop-protocol/issues/561"
note: "refinement approved → impl-review-loop 停止の handoff gap を contract gate で解消する"
Activity
squne121 commentedon Jun 2, 2026
結論
Verdict: REQUEST_CHANGES。#564 は方向性は正しいが、このまま実装に渡すと失敗しやすいです。
主因は、#560/#563 との責務重複、現行
impl-review-loopの「go コメントがなければ issue-contract-review を自動実行する」挙動との衝突、実在しない Allowed Path、body_sha256の producer 契約未確定です。#564 自体は「refinement approved を implementation-ready と誤読する gap」を塞ぐ Issue で、CONTRACT_REVIEW_RESULT_V1 status: goをimpl-review-loopの intake gate にする設計です。([GitHub]1)公開ページ上で確認できる範囲では、#564 自体にはまだ紐づく PR はなく、Development も空です。([GitHub]1)
関連 Issue / PR の読み合わせ
#564 は #561 を再現元として参照しています。#561 は WSL2/Ubuntu human playtest runbook と preflight を追加する implementation issue で、本文上は
phase/implementation相当の Issue に見えますが、#564 が問題にしているのは「refinement approve 済みでも contract go がないなら implementation-ready ではない」という handoff gap です。([GitHub]2)#561 には PR #565 が紐づき、preflight script、manual runbook、WSL2 runtime 検証、CI 通過、review approve まで進んでいます。したがって #564 の regression fixture は、実 Issue/PR 状態に依存するのではなく、「#561 型の metadata は揃っているが
CONTRACT_REVIEW_RESULT_V1 status: goがない」最小 fixture として hermetic に作るべきです。([GitHub]3)重大なのは #560/#563 との重複です。#560 はすでに
issue-refinement-loopの完了条件にissue-contract-review gateを追加する Issue で、latestCONTRACT_REVIEW_RESULT_V1.status == "go"、snapshot idempotency、body freshness invalidation を扱っています。([GitHub]4) PR #563 も同じ方向の docs 変更を含み、termination-policy / dor / workflow を更新して test/build 通過、review approve まで進んでいます。([GitHub]5)つまり #564 は、#560/#563 が merge 済みである前提に立つ consumer-side gate に絞るか、#560/#563 を supersede する Issue として再定義する必要があります。現状のままだと、同じ「final go gate」を複数 Issue が別名・別状態で定義し、loop state が drift します。
Blocker 1: Allowed Paths が現行 repo と合っていない
#564 の Allowed Paths には
impl-review-loop/references/preparation.mdが「存在する場合」として出ていますが、現行 main ではこの path は存在せず、実体は.claude/skills/impl-review-loop/steps/preparation.mdです。実際の preparation は、missing snapshot 時に issue comments からstatus: goを探し、なければissue-contract-reviewを自動実行する設計になっています。([GitHub]6)これは単なる path typo ではありません。#564 の主対象が intake gate なら、変更対象は少なくとも以下です。
Issue 本文の Allowed Paths は修正必須です。Codex/Claude worker に渡すと、存在しない path を探索して無駄な実装判断を始めます。
Blocker 2:
missing_contract_goと「自動 issue-contract-review 実行」が衝突している現行
impl-review-loopは、contract_snapshot_urlがなければ issue comments から validgoを探し、見つからなければissue-contract-reviewを auto-run する流れです。([GitHub]6)一方 #564 は、
CONTRACT_REVIEW_RESULT_V1 status: goをimpl-review-loop preparationの必須入力にし、失敗理由としてmissing_contract_go/metadata_not_ready/stale_contract_review/body_snapshot_mismatchを導入しようとしています。([GitHub]1)ここは設計決定が必要です。
推奨は fail-only gate です。
impl-review-loopはissue-contract-reviewを自動実行せず、最新の valid go がなければintake_gate_failed: missing_contract_goで停止する。gate 判定と成果物生成を同じ loop がやると、control-plane が gate と作業生成を混ぜる構造に戻ります。代替案として auto-materialization を残すなら、#564 の failure taxonomy は破綻します。
missing_contract_goは「自動生成に失敗した後の状態」になるため、Issue 名と AC を書き換えるべきです。Blocker 3:
body_sha256は producer 契約が未確定#564 は
body_sha256/ comment freshness による stale 検出を求めています。([GitHub]1) しかし #560/#563 側では、producer-side のbody_sha256出力は out-of-scope 気味で、当面はgenerated_atと Issueupdated_atの比較による stale check が現実的です。([GitHub][7])したがって #564 は次のどちらかに倒す必要があります。
producer 契約を別 Issue に切る
issue-contract-reviewがbody_sha256を必ず emit するようにする。その Issue が merge されるまで 実装: issue-refinement-loop と impl-review-loop の implementation-ready handoff を contract gate 化する #564 は blocked。consumer fallback を仕様化する
body_sha256がある場合は hash 比較。ない場合はgenerated_at < issue.updated_atをstale_contract_reviewとする。ただしこれは edit noise に弱い暫定判定。この明記がないと、実装者は「body_sha256 がない古い go comment」を valid として通すか、逆に全件 stale にして運用を止めます。
Blocker 4:
REQUEST_CHANGESの意味が未定義#564 は「REQUEST_CHANGES 後の stale go」を止めたい趣旨ですが、
REQUEST_CHANGESの source が曖昧です。GitHub には issue comments、PR review comments、timeline events、review state など複数のイベント面があります。Issue comments API は issue/PR の一般コメントを扱い、PR も issue として扱われますが、PR の line review comment や review state は別面です。([GitHub Docs][8])最低限、次を定義してください。
個人的には、free text の
REQUEST_CHANGES検出は避けるべきです。CONTRACT_REVIEW_RESULT_V1と同様に machine-readable block に寄せるべきです。free text は引用・例示・過去ログで false positive になります。Blocker 5: failure reason の優先順位がない
#564 の failure subreason は並んでいますが、複数同時に成立する場合の precedence がありません。これは regression test の不安定化要因です。
推奨 precedence はこれです。
ただし
request_changes_after_goは #564 の列挙にありません。追加を推奨します。REQUEST_CHANGES後に古い go が残っている状態をstale_contract_reviewに混ぜると、原因が「Issue body が変わった」のか「review verdict が更新された」のか分からなくなります。Blocker 6: metadata gate は GitHub の権限・確認仕様を考慮すべき
#564 は title prefix、phase label、dependency freshness を扱います。GitHub REST API では issue labels は update 時に replace され、push access がない場合 label 変更が silent drop され得ます。([GitHub Docs][9]) Label 取得は issue/PR 共通の issue endpoint 面で扱われます。([GitHub Docs][10])
したがって、将来 automation で title/label を直すなら、mutation 後に必ず read-back verification が必要です。#564 は automation 自体を out-of-scope にしていますが、gate としては read-only に固定し、
metadata_not_readyで止めるのが安全です。dependency についても、本文中の
Depends on文字列だけに頼らず、GitHub の issue dependencies API を使えるなら native dependency を正とすべきです。GitHub REST には “blocked by” dependencies を list/add/remove する endpoint が存在します。([GitHub Docs][11])推奨する再設計
#564 は次のように scope を狭めるのがよいです。
追加する machine-readable result はこの程度まで具体化した方がよいです。
追加すべき regression fixtures
最低限、以下の fixture を AC に入れてください。
GitHub issue comments are paginated, default 30 and max 100 per page, and comment ordering/fields such as
id,body,created_at,updated_atare available. Tests should simulate pagination instead of assuming one page.([GitHub Docs][8])Issue #564 へのコメント案
最終判断
#564 は「正しい問題」を扱っています。ただし現在の Issue contract は、gate producer / gate consumer / metadata automation / refinement-loop termination を一つに混ぜています。
実装前に次の 4 点を直せば、かなり品質が上がります。
impl-review-loopは auto-run ではなく fail-only intake gate にするbody_sha256とREQUEST_CHANGESの machine-readable 契約を定義するこの修正なしで進めると、また
approved/go/implementation-readyの意味が loop 間でズレます。# 既存衝突確認
git worktree list | grep "$WORKTREE" && echo "[WARN] worktree 既存" || echo "[OK] worktree 未作成"
git branch --list "$BRANCH" && echo "[WARN] branch 既存" || echo "[OK] branch 未作成"
```
既存衝突あり → 過去のイテレーションの残骸の可能性。人間判断を仰ぐ。
## 4. Product Spec Gate 評価完了後の LOOP_STATE 初期化
Product Spec Check 評価(1-d)を完了後、iteration = 0 で以下の状態で開始:
```yaml
LOOP_STATE:
issue_number:
contract_snapshot_url:
contract_snapshot_source: provided | detected_existing | materialized_by_issue_contract_review
iteration: 0
max_iterations: 3
worktree: .claude/worktrees/issue-<番号>-
branch: worktree-issue-<番号>-
last_step: null
last_loop_verdict: null
blockers_history: []
external_research_skip_basis: null
termination_reason: null
product_spec_preflight:
source: contract_snapshot.checks.product_spec_check
applicability: applicable | not_applicable | missing
decision: pass | fail | human_judgment | missing
blocked_rule_ids: []
contract_snapshot_url: ""
body_sha256: ""
routing_action: continue | stop_human | refresh_contract_snapshot
```
routing_action が
stop_humanまたはrefresh_contract_snapshotの場合は、ループを開始せず人間判断へ escalate する。## 5. 外部仕様調査スキップ判断(任意)
internal-only 変更(
src/state/src/systems内の純粋ロジック変更等)ならexternal_research_skip_basisに理由を記録してスキップ。外部仕様が絡む場合は
gemini-cli-headless-delegationを先行起動して情報を集める。## 出力
LOOP_STATE 初期値を会話履歴に明示記録し、Step 1(Implementation)へ進む。
"
[7]: https://raw.githubusercontent.com/squne121/loop-protocol/worktree-issue-560-issue-refinement-loop-issue-contract-rev/.claude/skills/issue-refinement-loop/references/termination-policy.md "raw.githubusercontent.com"
[8]: https://docs.github.com/rest/issues/comments "REST API endpoints for issue comments - GitHub Docs"
[9]: https://docs.github.com/rest/issues/issues "REST API endpoints for issues - GitHub Docs"
[10]: https://docs.github.com/rest/issues/labels "REST API endpoints for labels - GitHub Docs"
[11]: https://docs.github.com/en/rest/issues/issue-dependencies "REST API endpoints for issue dependencies - GitHub Docs"
squne121 commentedon Jun 2, 2026
Contract Snapshot (2026-06-02T03:54:00Z)
.claude/skills/issue-refinement-loop/の終了状態にrefinement_approved_gate_pending/implementation_ready区分が追加され、.claude/skills/impl-review-loop/steps/preparation.mdにCONTRACT_REVIEW_RESULT_V1 status: go必須 intake gate とintake_gate_failed4 サブ理由・body_sha256 freshness チェック・go 無効化 marker 定義が追記され、regression fixture が.claude/skills/impl-review-loop/tests/に追加された状態でpnpm test/pnpm buildが PASS している。refinement_approved_gate_pending状態がissue-refinement-loop定義に追加、issue-reviewer approveだけではimplementation_readyを返さないことが明文化impl-review-looppreparation にCONTRACT_REVIEW_RESULT_V1 status: go必須入力明記、intake_gate_failedと 4 サブ理由の優先順位が定義実装:/implement:) またはphase/implementationlabel 欠落 Issue がintake_gate_failed: metadata_not_readyになることが定義goコメントの freshness チェックが preparation gate に定義(body_sha256 / generated_at < issue.updated_at フォールバック)go無効化 marker が machine-readable block として定義(REVIEW_RESULT_V1.status == request_changesfenced yaml 形式).claude/skills/impl-review-loop/tests/に追加pnpm testPASS(回帰なし)pnpm buildPASS(回帰なし).claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/references/termination-policy.md.claude/skills/impl-review-loop/SKILL.md.claude/skills/impl-review-loop/steps/preparation.md.claude/skills/impl-review-loop/tests/(regression fixture 追加先).claude/worktrees/issue-564-issue-refinement-loop-impl-review-loop-iworktree-issue-564-issue-refinement-loop-impl-review-loop-isqune121 commentedon Jun 2, 2026
implement-issue: 実装完了 (2026-06-02T13:00:30Z)
```yaml
IMPLEMENT_RESULT_V1:
status: ok
generated_at: "2026-06-02T13:00:30Z"
generated_by: implement-issue
issue_url: #564
pr_url: #568
worktree: .claude/worktrees/issue-564-issue-refinement-loop-impl-review-loop-i
branch: worktree-issue-564-issue-refinement-loop-impl-review-loop-i
verification:
typecheck: skipped
lint: skipped
test:
passed: 313
failed: 0
files: 16
build: pass
allowed_paths_compliance: true
warnings: []
errors: []
```
fix(#564): address REQUEST_CHANGES — GO_INVALIDATION_POLICY_V1, on_in…
feat(#564): add implementation-ready handoff gate to impl-review-loop…
fix(#569): address REQUEST_CHANGES — Step 1-c routing, Section 6.4 LO…
docs(#569): impl-review-loop の contract blocked 3 分類ルーティングと worker 自律…
docs(#612): impl-review-loop SKILL.md の contract_snapshot_url 説明を fai…