Skip to content

実装: impl-review-loop Step 2 判定表に MERGEABLE+BEHIND の取り扱いを明文化 #52

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: impl-review-loop の TEST_VERDICT / LOOP_VERDICT / Step 2 / Step 5 が MERGEABLE+BEHIND を CONFLICTING/DIRTY/BLOCKED 扱いせず Step 4 / approved へ進める
change_kind: docs
related:
  - "#56: merge_state_status / mergeStateStatus の key 統一は別 Issue"
  - "#67: Step 5 BEHIND 分岐 + update-branch 自動化を扱う Issue(本 PR #439 で schema 拡張部分を absorb、#67 は update-branch 自動化のみ残る予定)"
scope_expanded_at: "2026-05-27T22:55:00Z"
scope_expansion_reason: "PR #439 への REQUEST_CHANGES (https://github.com/squne121/loop-protocol/pull/439#issuecomment-4559243138) により、Step 2 のみ修正は schema producer/consumer 不整合を生むことが判明。test-runner / pr-review-judge / Step 5 を同時修正する scope 拡張を人間承認"

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: impl-review-loop の TEST_VERDICT producer (test-runner)、LOOP_VERDICT consumer (pr-review-judge)、Step 2 routing、Step 5 mergeability handling のすべてが mergeable=MERGEABLE かつ merge_state_status=BEHIND の PR を CONFLICTING/DIRTY/BLOCKED と同列視せず、PR Review 継続および APPROVE 経路に載せる状態
  • Desired Destination: TEST_VERDICT.merge_state_status / LOOP_VERDICT.mergeStateStatus enum と Step 2 / Step 5 判定表の双方で BEHIND が mergeable-but-out-of-date 状態として一貫して扱われている状態

Current Validated Scope

  • .claude/skills/impl-review-loop/steps/step-2-verification.md: TEST_VERDICT.merge_state_status enum に BEHIND 追加、判定表に PASS + MERGEABLE + BEHIND => Step 4 行追加、CONFLICTING/DIRTY/BLOCKED 非同一視注記、Step 2 内 update-branch/rebase 非対応 + Step 5/実装: impl-review-loop Step 5 に BEHIND 分岐と auto update-branch を追加し schema を拡張する #67 委譲注記
  • .claude/agents/test-runner.md: TEST_VERDICT.merge_state_status enum に BEHIND 追加、BEHIND 検出時の FAIL 化を行わない(PASS 経路へ通す)旨を明記
  • .claude/skills/pr-review-judge/SKILL.md: LOOP_VERDICT.mergeStateStatus enum と「pass 条件」に BEHIND 追加、BEHIND を Conflict blocker / Merge blocker として REQUEST_CHANGES しない旨を明記
  • .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md: 判定表に APPROVE + MERGEABLE + BEHIND => approved 行追加(update-branch 自動化は 実装: impl-review-loop Step 5 に BEHIND 分岐と auto update-branch を追加し schema を拡張する #67 に分離)
  • .claude/agents/pr-reviewer-lite.md: mergeStateStatus enum に BEHIND 追加
  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md: mergeStateStatus enum に BEHIND 追加

Remaining Parent Gaps

  • #67: Step 5 / Step 2 の BEHIND 列挙値追加部分は本 PR で absorb 済み。#67 の残責務は gh pr update-branch 自動化と branch_behind_main schema 等の 挙動拡張 のみ
  • DRAFT / HAS_HOOKS の Step 2 / Step 5 における扱いは out-of-scope(follow-up Issue で扱う)

Outcome

下記 4 ファイル変更が main にマージされ、BEHIND を含む決定論的 grep がすべて pass する状態:

  1. .claude/skills/impl-review-loop/steps/step-2-verification.md
  2. .claude/agents/test-runner.md
  3. .claude/skills/pr-review-judge/SKILL.md
  4. .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md
  5. .claude/agents/pr-reviewer-lite.md
  6. .claude/skills/impl-review-loop/steps/step-4-pr-review.md

In Scope

  • 上記 4 ファイルの BEHIND 追加(enum + 判定表 + 注記)
  • PR description に Schema Consumer Inventory(TEST_VERDICT / LOOP_VERDICT の producer / consumer 影響)を明記
  • PR description に Safety Claim Matrix(.claude/skills/** 配下変更につき safety-sensitive=true 扱い)を明記
  • Step 2 / Step 5 の文書で BEHIND を CONFLICTING / DIRTY / BLOCKED と同一視しない旨を明記
  • update-branch / rebase 自動化は本 PR では実装せず #67 の責務として参照のみ

Out of Scope

Acceptance Criteria

  • AC1: step-2-verification.md の TEST_VERDICT.merge_state_status enum に BEHIND が含まれる
  • AC2: step-2-verification.md の判定表に PASS + MERGEABLE + BEHIND の行が存在し Step 4 へ進む旨を示す
  • AC3: step-2-verification.md に BEHIND を CONFLICTING / DIRTY / BLOCKED と同一視しない旨が明記されている
  • AC4: step-2-verification.md で Step 2 が update-branch / rebase を扱わず #67 / Step 5 に分離する旨が明記されている
  • AC5: test-runner.md の TEST_VERDICT.merge_state_status enum に BEHIND が含まれる
  • AC6: pr-review-judge/SKILL.md の LOOP_VERDICT.mergeStateStatus enum に BEHIND が含まれる
  • AC7: pr-review-judge/SKILL.md で mergeStateStatus=BEHIND が REQUEST_CHANGES の Conflict/Merge blocker に該当しない旨が明記されている
  • AC8: step-5-mergeability-handling.md の判定表に APPROVE + MERGEABLE + BEHIND => approved の行が存在する
  • AC9: pr-reviewer-lite.md の mergeStateStatus enum に BEHIND が含まれる
  • AC10: step-4-pr-review.md の mergeStateStatus enum に BEHIND が含まれる

Verification Commands

# AC1
$ rg -n 'merge_state_status:.*BEHIND' .claude/skills/impl-review-loop/steps/step-2-verification.md

# AC2
$ rg -n 'PASS.*MERGEABLE.*BEHIND.*Step 4' .claude/skills/impl-review-loop/steps/step-2-verification.md

# AC3
$ rg -n 'BEHIND.*(CONFLICTING|DIRTY|BLOCKED).*(同一視|該当しない|ではない)' .claude/skills/impl-review-loop/steps/step-2-verification.md

# AC4
$ rg -n '(update-branch|rebase).*(#67|Step 5)' .claude/skills/impl-review-loop/steps/step-2-verification.md

# AC5
$ rg -n 'merge_state_status:.*BEHIND' .claude/agents/test-runner.md

# AC6
$ rg -n 'mergeStateStatus:.*BEHIND' .claude/skills/pr-review-judge/SKILL.md

# AC7
$ rg -n 'BEHIND.*(blocker.*該当しない|REQUEST_CHANGES.*しない|conflict.*ではない)' .claude/skills/pr-review-judge/SKILL.md

# AC8
$ rg -n 'APPROVE.*MERGEABLE.*BEHIND.*approved' .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md

# AC9
$ rg -n 'mergeStateStatus:.*BEHIND' .claude/agents/pr-reviewer-lite.md

# AC10
$ rg -n 'mergeStateStatus:.*BEHIND' .claude/skills/impl-review-loop/steps/step-4-pr-review.md

baseline 期待: AC1〜AC4 は PR #439 既にマージ済(worktree 上)。AC5〜AC8 は main では未反映 → baseline fail。

Runtime Verification Applicability

decision: not_applicable
reason: docs-only change to .claude/skills/** and .claude/agents/test-runner.md. AC1-AC8 are deterministic rg-based text checks. No UI / runtime behavior / process startup affected.
policy_ref: docs/dev/runtime-verification-policy.md

Allowed Paths

  • .claude/skills/impl-review-loop/steps/step-2-verification.md
  • .claude/agents/test-runner.md
  • .claude/skills/pr-review-judge/SKILL.md
  • .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md
  • .claude/agents/pr-reviewer-lite.md
  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md

Stop Conditions

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

Required Skills

なし

Delivery Rule

1 Issue = 1 PR。Draft PR (#439) を継続使用し、AC 検証後に Ready for Review へ移行する。

Background

PR #49 観測で mergeable: MERGEABLE かつ mergeStateStatus: BEHIND の状態でも実装は妥当であることが確認された。
GitHub GraphQL MergeStateStatus.BEHIND は「head ref が base branch より古い」状態であり、MergeableState.MERGEABLE と両立するため CONFLICTING / DIRTY と同列視は意味論的に誤り(GitHub Docs)。

PR #439 初版は Allowed Paths を step-2-verification.md のみに絞ったが、TEST_VERDICT.merge_state_status enum を変更したため schema producer (test-runner.md) / consumer (pr-review-judge/SKILL.md, step-5-mergeability-handling.md) との不整合を生じる REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/439#issuecomment-4559243138)を受けた。本 Issue は scope を上記 4 ファイルに拡張し、docs/dev/schema-governance.md の Consumer Inventory 要件と pr-review-judge の Safety Claim Gate に対応する。

責務境界の確認:

  • #67 の残責務: gh pr update-branch 自動化、branch_behind_main 等の 挙動拡張 schema フィールド(本 PR は enum 値追加のみで absorb 済み)
  • #56 の責務: merge_state_status / mergeStateStatus の key 命名統一
  • implement-issue は producer 側手順であり対象外

branch protection 注記: "Require branches to be up to date before merging" が有効な場合、BEHIND は最終 merge 前に update が必要だが、それは Step 5 / #67 の責務であり、Step 2 / Step 4 ではレビュー継続を妨げない。

source: PR #49 post-merge follow-up, observation memo G, Issue #52 anchor comment (#52 (comment)), PR #439 REQUEST_CHANGES (#439 (comment))

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    agent/implementer
    on May 19, 2026
  2. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    「.claude/skills/impl-review-loop/steps/step-2-verification.md」ではなく .claude/skills/implement-issue や .claude/skills/pr-review-judge や .claude/agents/test-runner.md で検知すべきでは?

  3. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    結論: その人間コメントは概ね正しいです。ただし「step-2-verification.md ではなく」ではなく、「step-2-verification.md だけに閉じるのが誤り」が正確です。

    #52 は現在、Allowed Paths を .claude/skills/impl-review-loop/steps/step-2-verification.md だけに限定し、他ステップ変更も Out of Scope にしています。(GitHub) しかし実際の責務境界を見ると、impl-review-loop は「実装→検証→PRレビュー」を束ねる orchestrator で、Step 2 は test-runner に検証を委譲し、Step 4 は pr-reviewer / pr-review-judge に委譲します。(GitHub)

    採るべき責務分担

    場所 | 役割 | #52での扱い -- | -- | -- .claude/agents/test-runner.md | mergeable / mergeStateStatus の一次検知・TEST_VERDICT 生成 | 修正必須 .claude/skills/pr-review-judge/SKILL.md | APPROVE / REQUEST_CHANGES の最終判定ゲート | 修正必須 .claude/skills/impl-review-loop/steps/step-2-verification.md | test-runner の結果を読んで loop routing するだけ | 追従修正は必要 .claude/skills/implement-issue/SKILL.md | 実装、VC実行、PR作成まで | 原則ここではない

    test-runner はすでに gh pr view <PR番号> --json mergeable,mergeStateStatus を実行する設計で、説明にも「mergeable 状態の検知も担当」とあります。(GitHub) ただし現在の TEST_VERDICT schema は merge_state_status: CLEAN | DIRTY | BLOCKED | UNSTABLE | UNKNOWN で、BEHIND が抜けています。(GitHub) ここが一次バグです。

    pr-review-judge 側も同様に、TEST_VERDICT_MACHINE から mergeable と merge_state_status を読む設計なのに、判定では MERGEABLE + CLEAN|UNSTABLE だけを通過条件にしています。(GitHub) つまり BEHIND を test-runner が正しく出しても、review gate が通さない可能性があります。

    GitHub公式の GraphQL enum では、BEHIND は「head ref が out of date」、DIRTY は「merge commit を clean に作れない」、MERGEABLE は「PR can be merged」、CONFLICTING は「merge conflicts により merge できない」と定義されています。したがって MERGEABLE + BEHIND を CONFLICTING / DIRTY と同列に扱うのは意味論的に誤りです。(GitHub Docs)

    Issue #52 への敵対的判断

    現在の #52 は REQUEST_CHANGES 相当です。

    理由は、問題の発生源を impl-review-loop Step 2 の表現不足 として過小定義しているためです。PR #49 の観測メモでは「MERGEABLE だが BEHIND」「CLEAN/UNSTABLE のみ APPROVE 可と読める」とされ、改善先を step-2-verification.md に限定しています。(GitHub) しかし現行実装では test-runner の出力 schema と pr-review-judge の判定表にも同じ欠落があります。step-2 だけ直すと、orchestrator 文書だけが正しくなり、実際の検知・最終判定は壊れたまま残ります。

    推奨する人間コメント案

    この Issue は scope が狭すぎると思います。
    

    MERGEABLE + BEHIND の扱いは .claude/skills/impl-review-loop/steps/step-2-verification.md の routing 表だけでなく、実際に mergeable / mergeStateStatus を取得・報告する .claude/agents/test-runner.md と、最終的に APPROVE / REQUEST_CHANGES を判定する .claude/skills/pr-review-judge/SKILL.md の責務にも跨っています。

    特に現状では:

    • test-runner.md は gh pr view &lt;PR番号&gt; --json mergeable,mergeStateStatus を実行する設計だが、TEST_VERDICT.merge_state_status の enum に BEHIND が含まれていない
    • pr-review-judge/SKILL.md は mergeable=MERGEABLE かつ mergeStateStatus=CLEAN|UNSTABLE のみを通過条件としており、BEHIND を許容していない
    • impl-review-loop/steps/step-2-verification.md はその結果を routing する consumer なので、ここだけ直しても検知・最終判定の実体は直らない

    したがって、この Issue は少なくとも以下を Allowed Paths に含めるべきです。

    • .claude/agents/test-runner.md
    • .claude/skills/pr-review-judge/SKILL.md
    • .claude/skills/impl-review-loop/steps/step-2-verification.md

    一方で .claude/skills/implement-issue は、実装・VC実行・PR作成までの producer 側手順であり、PR mergeability の最終判定ゲートではないため、ここに BEHIND 判定を持たせるのは責務過多だと思います。

    修正方針は「Step 2 判定表に1行追加」ではなく、MERGEABLE + BEHIND を CONFLICTING / DIRTY / BLOCKED ではない mergeable-but-out-of-date 状態として、test-runner の出力 schema、pr-review-judge の gate、impl-review-loop の routing 表で一貫して扱う、に変更したいです。

    最小修正方針

    #52 は閉じずに直すなら、タイトルを次のように変えるのが妥当です。

    実装: MERGEABLE+BEHIND を test-runner / pr-review-judge / impl-review-loop で一貫して許容する

    Allowed Paths は最低限これです。

    - .claude/agents/test-runner.md

    • .claude/skills/pr-review-judge/SKILL.md
    • .claude/skills/impl-review-loop/steps/step-2-verification.md

    implement-issue は今回は外してよいです。ここに入れると「PR状態の検知」と「実装作業」が混ざり、責務境界が悪化します。

    ([[Past chat](https://chatgpt.com/c/6a0f1710-fa30-83e8-ad41-24c10af2c392)][1])([[Past chat](https://chatgpt.com/c/6a127f0e-11a4-83e8-bd0a-03d487df6673)][2])([[Past chat](https://chatgpt.com/c/6a110213-865c-83e8-a78f-62698736b910)][3])([[Past chat](https://chatgpt.com/c/6a162dab-542c-83e8-8523-dc97a17a0b6c)][4])([[Past chat](https://chatgpt.com/c/6a0f7c47-1174-83e9-9a9b-48bb113f5ac7)][5])([[Past chat](https://chatgpt.com/c/6a110223-2cc4-83e8-ac17-9a8a3022451a)][6])([[Past chat](https://chatgpt.com/c/6a174a67-5d5c-83e8-b44c-bcabc9a27727)][7])([[Past chat](https://chatgpt.com/c/6a16f963-f978-83e8-866c-a8b3d8130fad)][8])([[Past chat](https://chatgpt.com/c/6a110f2e-9f80-83e8-832a-8f476804b98d)][9])([[Past chat](https://chatgpt.com/c/6a125253-a148-83e8-8f7c-3b0286e440a8)][10])([[Past chat](https://chatgpt.com/c/6a12dea9-6b94-83e8-a014-34317f8fd915)][11])([[Past chat](https://chatgpt.com/c/6a118f70-5578-83e8-9124-7247cc445b95)][12])([[Past chat](https://chatgpt.com/c/6a126619-7c28-83e8-a344-c494f126a9b4)][13])([[Past chat](https://chatgpt.com/c/6a1265fa-6694-83e9-beea-1c280d7bfd74)][14])([[Past chat](https://chatgpt.com/c/6a129c23-71d4-83e8-ba76-3116286aa8c4)][15])([[Past chat](https://chatgpt.com/c/6a0ee4e2-8e20-83e9-b9df-32e83c1bac3c)][16])([[Past chat](https://chatgpt.com/c/6a114ffe-35c8-83e8-b0e9-de8e2a387c6d)][17])([[Past chat](https://chatgpt.com/c/6a10f60b-5724-83e8-88d0-ada6f99e256c)][18])([[Past chat](https://chatgpt.com/c/6a161b59-d5bc-83e9-91e3-2532dbdfa277)][19])([[Past chat](https://chatgpt.com/c/6a126abf-4e50-83e9-be92-84fadb9d9680)][20])([[Past chat](https://chatgpt.com/c/6a0f1f8f-64d0-83e8-8310-df073f256444)][21])([[Past chat](https://chatgpt.com/c/6a11935d-52f4-83e8-8332-9d1879f175c5)][22])([[Past chat](https://chatgpt.com/c/6a115c7e-d60c-83e8-bf8a-33446c77bec1)][23])([[Past chat](https://chatgpt.com/c/6a1264b1-9eec-83e8-a0e4-b10745a6971b)][24])([[Past chat](https://chatgpt.com/c/6a12a215-c848-83e8-be71-5ef3365556fe)][25])([[Past chat](https://chatgpt.com/c/6a0db1c7-e9a4-83e9-bc52-877e772f6b68)][26])([[Past chat](https://chatgpt.com/c/6a127aaf-1ae0-83e8-819f-baf78a2a9b36)][27])([[Past chat](https://chatgpt.com/c/6a1753bd-95ec-83e9-918f-770bd34aa224)][28])([[Past chat](https://chatgpt.com/c/6a09b66e-3ca4-83e8-be68-83d9594d9ce6)][29])([[Past chat](https://chatgpt.com/c/6a0e3816-8880-83e8-90a6-030935f2e749)][30])([[Gmail](https://mail.google.com/mail/#all/19d8949a7b5f318c)][31])([[Gmail](https://mail.google.com/mail/#all/19d8949a7703207b)][32])([[Gmail](https://mail.google.com/mail/#all/19e4050db3652270)][33])([[Gmail](https://mail.google.com/mail/#all/19e4054a978e315e)][34])([[Gmail](https://mail.google.com/mail/#all/19e405c2a872231a)][35])([[Gmail](https://mail.google.com/mail/#all/19e40c640fc80e0d)][36])([[Gmail](https://mail.google.com/mail/#all/19e41a5d603e4e66)][37])([[Gmail](https://mail.google.com/mail/#all/19d89419ae7ce12f)][38])([[Gmail](https://mail.google.com/mail/#all/19d893c88c31f8a8)][39])([[Gmail](https://mail.google.com/mail/#all/19d893c874df5b8a)][40])([[Gmail](https://mail.google.com/mail/#all/19d893c865829e6d)][41])([[Gmail](https://mail.google.com/mail/#all/19d893c852cc18eb)][42])([[Files](file://my_files/file_00000000d5d472069c2cc8cf0cacf1b4)][43])([[Files](file://my_files/file_00000000278072069781cc69a065e297)][44])([[Files](file://my_files/file_0000000022107207982a0b9798058548)][45])([[Files](file://my_files/file_00000000d7287206ac522b5f35dbe137)][46])([[Files](file://my_files/file_00000000f5987209aacfee825fc17d1d)][47])

    結論: その人間コメントは概ね正しいです。ただし「step-2-verification.md ではなく」ではなく、「step-2-verification.md だけに閉じるのが誤り」が正確です。

    #52 は現在、Allowed Paths を .claude/skills/impl-review-loop/steps/step-2-verification.md だけに限定し、他ステップ変更も Out of Scope にしています。([GitHub]48) しかし実際の責務境界を見ると、impl-review-loop は「実装→検証→PRレビュー」を束ねる orchestrator で、Step 2 は test-runner に検証を委譲し、Step 4 は pr-reviewer / pr-review-judge に委譲します。([GitHub]49)

    採るべき責務分担

    場所 役割 #52での扱い
    .claude/agents/test-runner.md mergeable / mergeStateStatus の一次検知・TEST_VERDICT 生成 修正必須
    .claude/skills/pr-review-judge/SKILL.md APPROVE / REQUEST_CHANGES の最終判定ゲート 修正必須
    .claude/skills/impl-review-loop/steps/step-2-verification.md test-runner の結果を読んで loop routing するだけ 追従修正は必要
    .claude/skills/implement-issue/SKILL.md 実装、VC実行、PR作成まで 原則ここではない

    test-runner はすでに gh pr view <PR番号> --json mergeable,mergeStateStatus を実行する設計で、説明にも「mergeable 状態の検知も担当」とあります。([GitHub]50) ただし現在の TEST_VERDICT schema は merge_state_status: CLEAN | DIRTY | BLOCKED | UNSTABLE | UNKNOWN で、BEHIND が抜けています。([GitHub]50) ここが一次バグです。

    pr-review-judge 側も同様に、TEST_VERDICT_MACHINE から mergeable と merge_state_status を読む設計なのに、判定では MERGEABLE + CLEAN|UNSTABLE だけを通過条件にしています。([GitHub]51) つまり BEHIND を test-runner が正しく出しても、review gate が通さない可能性があります。

    GitHub公式の GraphQL enum では、BEHIND は「head ref が out of date」、DIRTY は「merge commit を clean に作れない」、MERGEABLE は「PR can be merged」、CONFLICTING は「merge conflicts により merge できない」と定義されています。したがって MERGEABLE + BEHIND を CONFLICTING / DIRTY と同列に扱うのは意味論的に誤りです。([GitHub Docs]52)

    Issue #52 への敵対的判断

    現在の #52 は REQUEST_CHANGES 相当です。

    理由は、問題の発生源を impl-review-loop Step 2 の表現不足 として過小定義しているためです。PR #49 の観測メモでは「MERGEABLE だが BEHIND」「CLEAN/UNSTABLE のみ APPROVE 可と読める」とされ、改善先を step-2-verification.md に限定しています。([GitHub]53) しかし現行実装では test-runner の出力 schema と pr-review-judge の判定表にも同じ欠落があります。step-2 だけ直すと、orchestrator 文書だけが正しくなり、実際の検知・最終判定は壊れたまま残ります。

    推奨する人間コメント案

    この Issue は scope が狭すぎると思います。
    
    `MERGEABLE + BEHIND` の扱いは `.claude/skills/impl-review-loop/steps/step-2-verification.md` の routing 表だけでなく、実際に `mergeable / mergeStateStatus` を取得・報告する `.claude/agents/test-runner.md` と、最終的に APPROVE / REQUEST_CHANGES を判定する `.claude/skills/pr-review-judge/SKILL.md` の責務にも跨っています。
    
    特に現状では:
    
    - `test-runner.md` は `gh pr view <PR番号> --json mergeable,mergeStateStatus` を実行する設計だが、`TEST_VERDICT.merge_state_status` の enum に `BEHIND` が含まれていない
    - `pr-review-judge/SKILL.md` は `mergeable=MERGEABLE` かつ `mergeStateStatus=CLEAN|UNSTABLE` のみを通過条件としており、`BEHIND` を許容していない
    - `impl-review-loop/steps/step-2-verification.md` はその結果を routing する consumer なので、ここだけ直しても検知・最終判定の実体は直らない
    
    したがって、この Issue は少なくとも以下を Allowed Paths に含めるべきです。
    
    - `.claude/agents/test-runner.md`
    - `.claude/skills/pr-review-judge/SKILL.md`
    - `.claude/skills/impl-review-loop/steps/step-2-verification.md`
    
    一方で `.claude/skills/implement-issue` は、実装・VC実行・PR作成までの producer 側手順であり、PR mergeability の最終判定ゲートではないため、ここに `BEHIND` 判定を持たせるのは責務過多だと思います。
    
    修正方針は「Step 2 判定表に1行追加」ではなく、`MERGEABLE + BEHIND` を `CONFLICTING / DIRTY / BLOCKED` ではない mergeable-but-out-of-date 状態として、test-runner の出力 schema、pr-review-judge の gate、impl-review-loop の routing 表で一貫して扱う、に変更したいです。

    最小修正方針

    #52 は閉じずに直すなら、タイトルを次のように変えるのが妥当です。

    実装: MERGEABLE+BEHIND を test-runner / pr-review-judge / impl-review-loop で一貫して許容する

    Allowed Paths は最低限これです。

    - `.claude/agents/test-runner.md`
    - `.claude/skills/pr-review-judge/SKILL.md`
    - `.claude/skills/impl-review-loop/steps/step-2-verification.md`

    implement-issue は今回は外してよいです。ここに入れると「PR状態の検知」と「実装作業」が混ざり、責務境界が悪化します。

  4. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    Issue #52 の問題意識は正しいです。PR #49 で実際に mergeable: MERGEABLE かつ mergeStateStatus: BEHIND の状態でも全 AC が通り、レビュアーは APPROVE していました。一方で、現行 Step 2 の判定表は CLEAN/UNSTABLE しか APPROVE 経路に載せておらず、BEHIND が欠落しています。これは Issue #52 の主張どおり補正すべきです。([GitHub]1)

    ただし、Issue #52 の現在のスコープと AC のまま実装すると、仕様の一貫性が壊れる可能性が高いです。Step 2 の表だけに BEHIND 行を足すのでは不足です。


    ブロッカー

    1. Step 2 の schema enum が BEHIND を許していない

    Issue #52 は「Step 2 判定表に MERGEABLE + BEHIND を追加」としていますが、現行の step-2-verification.md は TEST_VERDICT の merge_state_status を CLEAN | UNSTABLE | DIRTY | BLOCKED | UNKNOWN と定義しており、BEHIND が enum に入っていません。つまり、表に BEHIND 行を足しても、同じ文書内の schema と矛盾します。([GitHub]2)

    修正要求: Issue #52 の In Scope に「Step 2 の TEST_VERDICT.merge_state_status enum に BEHIND を追加する」を明記してください。表だけでは不十分です。


    2. AC3 / VC3 が現在の baseline でも通る弱い検証になっている

    Issue #52 の AC3 は「BEHIND は CONFLICTING ではない、runbook 発動条件ではない」とする意図ですが、提示されている verification は grep -q "CONFLICTING" に近く、現行 Step 2 には既に CONFLICTING / DIRTY 行があるため、実装前から通る false positive になります。([GitHub]3)

    修正要求: BEHIND と CONFLICTING / DIRTY / Runbook の関係を同じ近傍で検証する grep に変えてください。

    例:

    FILE=.claude/skills/impl-review-loop/steps/step-2-verification.md
    
    grep -nE 'merge_state_status: .*BEHIND' "$FILE"
    grep -nE 'BEHIND.*(CONFLICTING|DIRTY).*ではない|BEHIND.*Runbook.*発動条件.*該当しない' "$FILE"

    3. BEHIND を「merge 時に自動解決される」と言い切るのは危険

    GitHub GraphQL の MergeStateStatus.BEHIND は「head ref が out of date」という状態であり、MergeableState.MERGEABLE とは別軸です。MERGEABLE + BEHIND はコンフリクトを直接意味しませんが、branch protection で「merge 前に base branch へ追随していること」が要求されている場合、更新・rebase・再チェックが必要になります。([GitHub Docs]4)

    修正要求: Step 2 の文言は「Step 4 へ進める / review 可能」に留めるべきです。
    「merge 時に自動解決」「rebase 不要」と読める文言は避けてください。BEHIND の更新処理は Step 5 / Issue #67 の責務に分離するのが妥当です。


    4. #52 は #67 と #56 への依存関係を明記しないと破綻する

    関連 Issue #67 は、まさに Step 5 側で BEHIND 分岐、gh pr update-branch、branch_behind_main、reviewer recommendations を扱う設計です。さらに #67 は #52 の merge 後に進める前提になっています。([GitHub]5)

    また #56 は mergeStateStatus と merge_state_status の key 混在を直す Issue です。PR #49 の観測でも、TEST_VERDICT は snake_case、LOOP_VERDICT は camelCase、Step 5 grep は camelCase という不一致が確認されています。([GitHub]1)

    修正要求: Issue #52 に以下を明記してください。

    Related / Dependency:
    - #52: Step 2 で MERGEABLE + BEHIND を PR Review へ進める判定として明文化する。
    - #67: Step 5 側の update-branch / BEHIND 分岐は別 Issue で扱う。
    - #56: merge_state_status / mergeStateStatus の key 統一は別 Issue で扱う。

    5. 「SubAgent が PR mergeability を誤判定しない」はスコープ過大

    Issue #52 の目的は Step 2 の判定表補正ですが、実際には test-runner.md、pr-review-judge/SKILL.md、Step 4、Step 5 の schema も BEHIND を完全には扱えていません。特に pr-review-judge は MERGEABLE + CLEAN/UNSTABLE のみを通常経路としており、Step 5 も CLEAN/UNSTABLE しか approve exit にしていません。([GitHub]6)

    修正要求: #52 のゴールを狭めてください。

    悪い例:

    SubAgent が BEHIND PR を誤判定しない。

    良い例:

    Step 2 は TEST_VERDICT が PASS かつ mergeable=MERGEABLE かつ merge_state_status=BEHIND の場合、CONFLICTING/DIRTY/BLOCKED 扱いせず Step 4 へ進める。
    Step 4/5、pr-review-judge、update-branch automation は #67/#56 の責務とする。

    推奨する Issue #52 の修正版スコープ

    ## In Scope
    
    - `.claude/skills/impl-review-loop/steps/step-2-verification.md` の
      `TEST_VERDICT.merge_state_status` enum に `BEHIND` を追加する。
    - Step 2 判定表に以下を追加する:
      - `PASS + MERGEABLE + BEHIND` => Step 4 PR Review へ進む。
    - `BEHIND` は head ref が base branch より古い状態であり、
      `CONFLICTING` / `DIRTY` / `BLOCKED` と同一視しないことを明記する。
    - branch update / rebase / `gh pr update-branch` は Step 5 / #67 の責務として分離する。
    ## Out of Scope
    
    - Step 4 / Step 5 の update-branch 実装。
    - `gh pr update-branch` の自動実行。
    - `mergeStateStatus` / `merge_state_status` の全体統一。これは #56 で扱う。
    - `DRAFT` / `HAS_HOOKS` など GitHub enum 全体の網羅化。

    推奨 AC / VC

    ### AC1: Step 2 schema が BEHIND を受け入れる
    
    `TEST_VERDICT.merge_state_status` の enum に `BEHIND` が含まれる。
    
    Verification:
    
    ```bash
    grep -nE 'merge_state_status: .*BEHIND' .claude/skills/impl-review-loop/steps/step-2-verification.md

    AC2: MERGEABLE + BEHIND は Step 4 へ進む

    判定表に PASS + MERGEABLE + BEHIND => Step 4 が存在する。

    Verification:

    grep -nE 'PASS.*MERGEABLE.*BEHIND.*Step 4' .claude/skills/impl-review-loop/steps/step-2-verification.md

    AC3: BEHIND は conflict runbook 条件ではない

    BEHIND を CONFLICTING / DIRTY / BLOCKED と同一視しない注記がある。

    Verification:

    grep -nE 'BEHIND.*(CONFLICTING|DIRTY|BLOCKED).*ではない|BEHIND.*Runbook.*発動条件.*該当しない' .claude/skills/impl-review-loop/steps/step-2-verification.md

    AC4: update-branch は Step 2 で扱わない

    Step 2 は review へ進めるだけで、branch update / rebase / merge automation を実行しない。

    Verification:

    grep -nE 'update-branch|rebase|Step 5|#67' .claude/skills/impl-review-loop/steps/step-2-verification.md
    
    ---
    
    ## 外部仕様に基づく最終判断
    
    GitHub の状態モデル上、`MERGEABLE` と `BEHIND` は両立します。`BEHIND` は「古い」だけで、直接の conflict ではありません。したがって Step 2 で conflict runbook に落とすのは誤りです。一方、branch protection や required status checks により、merge 前に branch update が必要になるケースはあります。`gh pr update-branch` は base branch の最新状態を PR branch に取り込むための CLI で、デフォルトは merge commit、`--rebase` で rebase になります。:contentReference[oaicite:7]{index=7}
    
    したがって、#52 は **「Step 2 で BEHIND をブロックしない」Issue としては妥当**です。ただし、現在のままだと schema、AC、関連 Issue 連携が弱く、後続の #67/#56 と衝突しやすい。  
    実装前に上記の修正を入れるべきです。
    ::contentReference[oaicite:8]{index=8}
    
  5. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop result

    Applied changes

    anchor comment の REQUEST_CHANGES 指摘に従って Issue 本文を以下のとおり書き換えました。

    1. In Scope: TEST_VERDICT.merge_state_status enum への BEHIND 追加、判定表行追加、CONFLICTING/DIRTY/BLOCKED 非同一視の注記、update-branch/rebase は #67 に分離を追記
    2. Out of Scope: test-runner.md / pr-review-judge/SKILL.md の修正は #67 の責務、key 命名統一は #56 の責務に明示分離
    3. Acceptance Criteria: AC1 (enum)、AC2 (判定表行)、AC3 (非同一視注記)、AC4 (update-branch/rebase 分離) の 4 つに再構成
    4. Verification Commands: rg ベースの決定論的 grep に統一。AC3 は baseline で fail することを担保(旧 VC は CONFLICTING の単純 grep で false positive だった指摘を反映)
    5. Related: #56 / #67 への依存関係を Machine-Readable Contract.related に明記
    6. Runtime Verification Applicability: decision: not_applicable(docs-only / 決定論的 rg 検証)を追加
    7. Background: BEHIND を「merge 時に自動解決」と言い切る記述は削除し、MergeStateStatus.BEHIND の意味論と責務境界を明確化

    Deterministic checks (check_issue_contract.py)

    C1〜C13 すべて pass / n/a、blocking_issues なし。

    Allowed Paths

    .claude/skills/impl-review-loop/steps/step-2-verification.md のみ(anchor comment の最終結論どおり狭く維持し、test-runner / pr-review-judge への波及は #67 へ escalate)。

    Next

    issue-contract-review skill で go 判定を取得後、implementation に着手可能。

  6. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-27T22:01:11Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-05-27T22:01:11Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/52
      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
          vc_expected_pass: 0
          vc_skipped: 0
          status: pass
          classifications:
            - ac: AC1
              command: "rg -n 'merge_state_status:.*BEHIND' .claude/skills/impl-review-loop/steps/step-2-verification.md"
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC2
              command: "rg -n 'PASS.*MERGEABLE.*BEHIND.*Step 4' .claude/skills/impl-review-loop/steps/step-2-verification.md"
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC3
              command: "rg -n 'BEHIND.*(CONFLICTING|DIRTY|BLOCKED).*(同一視|該当しない|ではない)' .claude/skills/impl-review-loop/steps/step-2-verification.md"
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC4
              command: "rg -n '(update-branch|rebase).*(#67|Step 5)' .claude/skills/impl-review-loop/steps/step-2-verification.md"
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
    • Outcome: .claude/skills/impl-review-loop/steps/step-2-verification.md に enum 追加・判定表行・非同一視注記・update-branch 分離が main にマージされている
    • Acceptance Criteria: AC1〜AC4 すべて決定論的 rg 検証
    • Verification Commands: 4 つ、baseline で全 fail(go)
    • Allowed Paths: .claude/skills/impl-review-loop/steps/step-2-verification.md
    • Worktree: .claude/worktrees/issue-52-step-2-mergeable-behind
    • Branch: worktree-issue-52-step-2-mergeable-behind
    • VC preflight: baseline fail = 4, 想定外 pass = 0, 実行不可 = 0
  7. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-27T22:03:48Z)

  8. added a commit that references this issue on May 27, 2026
  9. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    PR #439 拡張完了 — AC1-8 全 PASS

    人間承認によるスコープ拡張(AC5-8 + Allowed Paths 追加)を実装し、PR #439 を更新しました。

    AC 達成状況

    AC 対象ファイル 結果
    AC1 step-2-verification.md: merge_state_status enum に BEHIND PASS
    AC2 step-2-verification.md: PASS + MERGEABLE + BEHIND => Step 4 行 PASS
    AC3 step-2-verification.md: BEHIND を CONFLICTING/DIRTY/BLOCKED と同一視しない旨 PASS
    AC4 step-2-verification.md: update-branch/rebase は Step 5/#67 の責務 PASS
    AC5 test-runner.md: merge_state_status enum に BEHIND 追加 PASS
    AC6 pr-review-judge/SKILL.md: mergeStateStatus enum に BEHIND 追加 PASS
    AC7 pr-review-judge/SKILL.md: mergeStateStatus=BEHIND は Conflict/Merge blocker 非該当 PASS
    AC8 step-5-mergeability-handling.md: APPROVE + MERGEABLE + BEHIND => approved 行追加 PASS

    Regression Gate

    pnpm typecheck / lint / test / build、uv run pytest test_model_routing.py — 全 PASS

    Producer/Consumer 整合

    Schema Consumer Inventory を PR 本文に追記。TEST_VERDICT producer(test-runner.md)と全 consumer(step-2, step-5, pr-review-judge)を同一 PR 内で同期済み。

    PR: #439

  10. added a commit that references this issue on May 27, 2026
  11. squne121 commented on May 27, 2026

    @squne121
    OwnerAuthor

    AC1-10 全 PASS 報告(scope 2nd 拡張完了)

    PR #439 に 2 ファイル追加修正を commit・push しました。

    追加修正ファイル

    • .claude/agents/pr-reviewer-lite.md — mergeStateStatus enum に BEHIND を追加(AC9)
    • .claude/skills/impl-review-loop/steps/step-4-pr-review.md — mergeStateStatus enum に BEHIND を追加(AC10)

    VC PASS 確認

    AC 結果
    AC1 PASS
    AC2 PASS
    AC3 PASS
    AC4 PASS
    AC5 PASS
    AC6 PASS
    AC7 PASS
    AC8 PASS
    AC9 PASS (rg -n 'mergeStateStatus:.*BEHIND' .claude/agents/pr-reviewer-lite.md → L195)
    AC10 PASS (rg -n 'mergeStateStatus:.*BEHIND' .claude/skills/impl-review-loop/steps/step-4-pr-review.md → L25)

    Regression Gate

    コマンド 結果
    pnpm typecheck PASS
    pnpm lint PASS
    pnpm test PASS (7 files, 75 tests)
    pnpm build PASS
    uv run pytest test_model_routing.py PASS (21 tests)

    PR body の ## Schema Consumer Inventory に rg 実行結果を追加済み(全 consumer が BEHIND を含むことを確認)。

    PR: #439

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/implementationstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions