Skip to content

実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "impl-review-loop Step 4 が正規 ensure_contract_snapshot の出力を schema confusion なく current-head VC gate に渡せる"
change_kind: workflow
dedupe_key: "impl-review-loop:step4:ensure-envelope-to-adjudicator-snapshot-handoff"

Parent Issue

なし(独立した再発防止 Issue)。発見元: PR #2990(merged 済み)/ Issue #2979 の 2026-10-08 interactive Claude Code impl-review-loop 実行。

Parent Goal Ref

  • Goal: impl-review-loop Step 4 が、正規 producer(ensure_contract_snapshot.py)の出力を手作業の jq / 手組み JSON なしで current-head VC gate(step4-adjudicate)へ渡せる。
  • Desired Destination: 単独の再発防止修正であり親 Issue はない。Desired Destination はこの Issue 自身の Outcome と同一。

Current Validated Scope

  • steps/step-4-pr-review.md の snapshot 取得元・handoff 手順を実際の producer 出力(envelope・exit code)に合わせる。
  • adjudicate_vc_result.py の step4-adjudicate 入力処理に、source 別の snapshot 解決と全体正規化を追加する。
  • producer artifact → handoff → step4-adjudicate を接続する限定 integration regression を新規追加する。

Remaining Parent Gaps

なし(親 Issue なし)。以下は別 Issue が所有し、本 Issue では扱わない。

  • 自己投稿直後の updatedAt false-stale(post-publication readback/race): #3004(OPEN)
  • 同一 binding の VC/PASS 失効の production 配線一般: #2837(CLOSED 済み。同一 binding 失効は現 main に実装済み)

Problem / Reproduction

Step 4 の canonical 手順は --contract-snapshot-file に baseline VC classification を持つ正規 snapshot を要求し、取得元として ensure_contract_snapshot.py を案内している。一方、同 script の --artifact-dir が保存する contract-snapshot-<N>.json は CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 envelope であり、adjudicate_vc_result.py::_normalize_list_payload() が受理する CONTRACT_REVIEW_RESULT_V1 / CONTRACT_REVIEW_ONCE_RESULT_V1 / baseline_vc_preflight/v1 とは一致しない。

観測した再現経路(対象 #2979、PR #2990、当時の head b3c2ccc5...):

  1. ensure_contract_snapshot.py --issue-number 2979 --repo squne121/loop-protocol --mode dry-run --evidence-mode baseline --artifact-dir <scratch>/snap が source=materialized_go、contract_review_once_result.status=go の envelope を保存した(CLI の終了コードは 20)。
  2. adjudicate_vc_result.py step4-adjudicate --contract-snapshot-file <scratch>/snap/contract-snapshot-2979.json ... は overall_status=indeterminate、unsupported_schema:CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 で reviewer を起動できない。
  3. オペレーターが手で jq '.contract_review_once_result' ... と抽出すると gate が通った。

根拠(main 81b2c54f で確認した source):

  • ensure_contract_snapshot.py: --artifact-dir は全 status で envelope 全体を contract-snapshot-<N>.json に保存する。終了コードは ok→0、blocked_needs_refinement→10、human_judgment / dry_run_would_post→20、runtime_error / unknown→40、stale_or_conflicting_snapshot→50、controlled_publisher_binding_failed→60。
  • dry_run_would_post: source=materialized_go、contract_review_once_result.status=go、contract_snapshot_url=null。正常な候補生成だが exit 20 であり、human_judgment と同じ終了コードを共有する。
  • existing_go(baseline mode で有効な既存 snapshot を再利用): status=ok、contract_snapshot_url あり、contract_review_once_result=null が正常。nested result は再生成されない。
  • 既存 trusted comment は YAML の CONTRACT_REVIEW_RESULT_V1: wrapper で、classification は JSON 文字列として運ばれる。decode・trust・fingerprint は共有 parser contract_review_result_parser.py(parse_contract_review_results / find_latest_go)が担う。
  • adjudicate_vc_result.py: _normalize_list_payload() は envelope を受け付けず unsupported_schema:<schema> を返す。ただし後段は元の contract_snapshot を直接読む。_extract_source_integrity() は top-level body_sha256、_current_head_binding_error() は status == "go" と top-level body_sha256、evaluate_step4_vc_gate() は宣言順の command hashes(順序付きリスト比較)を使う。したがって _normalize_list_payload() 内だけで envelope を unwrap しても、body binding 欠落や contract_not_go で gate が閉じたままになり得る。
  • steps/step-4-pr-review.md: 必須入力と取得元の説明が envelope artifact と消費可能な snapshot を区別していない。
  • 同一 binding の stale PASS 失効は 実装: 再発防止: 独立 VC の正規消費経路を Step 2 / 4 / 5 に接続し、検証未了・失効後の approved を防ぐ #2837 で実装済み(step4_persist_vc_adjudication() が新結果で gate が開かないとき同一 binding key の保存済み entry を削除する)。handoff を step4-adjudicate の外側の前置コマンドで行い、失敗時に step4-adjudicate に到達しない構成にすると、この失効を迂回して古い PASS が --reuse-stored で再利用されるおそれがある。

Impact

正規 producer が成功しても Step 4 で false-blocked となり、手作業の jq / 手組み JSON / gate 再試行が必要になる。手編集の慣例化は evidence の来歴を曖昧にする。さらに handoff 失敗が既存の失効経路を迂回すると、古い PASS が再利用され得る。#2979 の post-merge cleanup 修正とは独立し、PR #2990 の Allowed Paths に含まれなかった。

Outcome

正規 producer の出力(dry-run 候補・既存 snapshot 再利用の両方)が、既存の binding を緩めず単一の documented handoff で step4-adjudicate に到達し、handoff 失敗後に同一 binding の古い PASS が再利用されない状態。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: repository-owned script・文書・subprocess integration test(deterministic fake GitHub boundary)で検証が完結し、実 Claude Code session / hook runtime を常設 gate にしないため

In Scope

  • Step 4 の snapshot handoff を documented canonical 手順として明確化する(steps/step-4-pr-review.md)。
  • step4-adjudicate に optional 引数 --producer-exit-code / --repo を追加する(既存の必須引数・既存 binding は変更しない)。
  • step4-adjudicate の既存入力処理へ、source 別に snapshot を解決して全体を一度だけ正規化し、同じ object を classification・source integrity・current-head binding に使う処理を追加する。
  • 限定 integration regression(producer artifact → handoff → step4-adjudicate)の新規追加。

Out of Scope

Acceptance Criteria

  • AC1: handoff は step4-adjudicate の既存入力処理の内側に置く(root の前置 normalizer / 前置 shell で envelope を加工して失敗時に step4-adjudicate へ到達しない構成にしない)。step4-adjudicate に optional 引数 --producer-exit-code <int> を追加する。--contract-snapshot-file の schema が CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 のとき必須とし、欠落・非整数・下表と不一致は fail-closed で拒否する(producer の終了コード自体は変更しない)。対応表: status=ok ⇔ exit 0、status=dry_run_would_post(source=materialized_go)⇔ exit 20、status=human_judgment は exit 20 でも常に拒否、その他 status(blocked_needs_refinement / runtime_error / stale_or_conflicting_snapshot / controlled_publisher_binding_failed / unknown)は常に拒否。dry_run_would_post / materialized_go の exit 20 は適合する候補 evidence の handoff を妨げず、適合する baseline evidence と独立 current-head evidence が揃えば invoke_pr_reviewer: true に到達して unsupported_schema は発生しない。dry-run 候補を投稿済み trusted snapshot や implementation authorization と同一視しない。envelope の解決は _run_step4_adjudicate / step4_adjudicate の入力前処理で行い、解決済みの canonical object を adjudicate_vc_result() に渡す(adjudicate / step4-gate subcommand は envelope 非対応のまま変更しない)。--producer-exit-code を envelope 以外の snapshot と同時に指定した場合は拒否する。
  • AC2: source 別に入力を解決し、(status, source, nested result, contract_snapshot_url) の許容組合せを次の表に固定する(これ以外は拒否)。(1) dry_run_would_post + materialized_go + nested status: go + url null(exit 20): nested result を候補 evidence の authority とし、schema・status: go・body binding を検証する。(2) ok + existing_go + url あり(baseline mode では nested null が正常、current-head mode で nested が非 null でも nested は authority にしない)、および (3) ok + materialized_go + url あり(--post 成功): いずれも contract_snapshot_url の comment を authority とし、既存 shared parser(contract_review_result_parser.py の fetch_issue_comments / parse_contract_review_results / find_latest_go)で、comment id 一致・trusted author・fingerprint ready・--expected-contract-body-sha256 との body digest 一致を再検証する(独自 YAML decode や .inner 抽出だけで済ませない。取得・解析・検証のいずれの失敗も拒否)。repo は envelope の値ではなく step4-adjudicate の optional 引数 --repo <owner/repo> から取り、envelope の issue_number と comment URL の issue を --expected-issue-number と束縛する(不一致・別 repo・別 Issue の comment は拒否)。ok 系 source では --repo と --expected-issue-number の両方を必須とし(baseline-only VC でも同様)、欠落は拒否する。dry_run_would_post では --repo を使わない。comment 選択規則は 1 つに固定する: contract_snapshot_url の comment id が、shared parser 経由の find_latest_go(trusted_only=True, fingerprint_ready_only=True) が返す最新の trusted かつ fingerprint-ready な status: go と一致すること。さらに find_latest_result(trusted_only=True) が返す最新 trusted result が blocked の場合は拒否する。fingerprint 未完成の provisional / orphan go(trusted だが fingerprint-ready でない)は新しい authoritative GO として扱わず、それだけでは既存の fingerprint-ready GO を失効させない(最新 trusted result の comment id と URL の comment id の一致は要求しない)。URL の go より新しい fingerprint-ready な trusted GO がある場合、または URL の go より新しい trusted blocked がある場合は拒否する。producer(ensure_contract_snapshot.py)が existing_go として選択・返却した artifact と consumer が同一の authoritative-result precedence を消費することを固定し、新規 predicate を作らない。trusted author・fingerprint・comment id・repo・Issue・body digest の束縛は維持する。outer failure(blocked_needs_refinement / human_judgment / runtime_error 等)に inner go が残っていても、body digest 不一致、無効な trusted source、malformed envelope も gate を開かない。jq による単純抽出や jq -e の追加だけでは解決済みとしない。
  • AC3: 解決後の snapshot を、schema: CONTRACT_REVIEW_RESULT_V1 相当の canonical 形(top-level の status / body_sha256 / checks.vc_preflight.classifications)として一度だけ構築し、その同じ object を classification(_normalize_list_payload())・source integrity(_extract_source_integrity())・current-head binding(_current_head_binding_error())に使う(_normalize_list_payload() の局所変更のみで済ませない)。changed head / Issue body SHA / 宣言順の command hashes(集合比較にしない)、pr_review_only / runtime_only の既存 binding、TEST_VERDICT_MACHINE/v2 の既存 binding と独立証跡を緩めない。手組み PASS JSON や手編集した LOOP_STATE に依存しない。handoff の失敗は step4-adjudicate の contract_snapshot_errors / 入力エラーとして既存の persist・失効経路(step4_persist_vc_adjudication)を必ず通す。
  • AC4: stateful regression を含む限定 integration test を新規追加する。AC2 の許容組合せ (1)(2)(3) をすべて少なくとも 1 ケースずつ通し、(2)(3) 用の trusted comment fixture は fake gh の状態保持 POST / PATCH / GET を使って producer の実 CLI(--post 経路)で生成する(手組み comment を直接置かない)。URL の go より新しい trusted blocked comment がある場合に gate が閉じるケースも含める。(a) public producer CLI の実 exit code と保存された実 artifact を使う。(b) existing_go の nested null envelope から shared trusted comment parser を経て snapshot を解決する。(c) step4-adjudicate の実 exit code・invoke_pr_reviewer・保存 binding を確認する。(d) outer failure に inner go が残る場合・body 不一致・malformed input で gate が閉じる。(e) 同一 binding の PASS 保存 → 新たな canonical adjudication の handoff 失敗 → 当該 PASS が --reuse-stored で再利用不能 → 無関係な binding は維持、という複数 invocation の系列を確認する。再検証を伴わない通常の --reuse-stored は従来どおり利用できる。 (f) 型不正 envelope(status / source が配列・object・非文字列、--producer-exit-code が巨大な十進数字列など整数変換に失敗する値、不正な nested result)は未処理例外にならず構造化された入力エラー(contract_snapshot_errors)として拒否され、既存の persist・失効経路を通る。(e) と同じ系列(A・B の PASS 保存 → A に型不正 envelope → 構造化拒否 → A の保存済み PASS 削除 → A の --reuse-stored 拒否 → B 維持)を実 CLI で固定する。(g) provisional GO 回帰: 最新 trusted の fingerprint 未完成 go(producer の実 POST 経路と失敗注入で生成する)が fingerprint-ready な go より新しい状態で、producer が返した ok / existing_go の artifact を consumer が受理する。最新 trusted blocked がある場合、および fingerprint-ready GO の id・body digest・repo・Issue の不一致と fetch failure は拒否する。GitHub 境界は PATH 上の fake gh shim(producer と consumer の両 subprocess が同じ fixture を使う)で deterministic にし、fixture の Issue 本文は自明に成功する最小 VC のみを持たせる(producer / consumer は mock ではなく実 CLI を subprocess で起動する)。実ネットワークや実 Claude Code session を常設 gate にしない。別 ledger・state writer・approval gate は追加せず、既存 consumer の失効処理を再利用する。修正前の実 failure class は assertion failure として固定する: 新規テストを base checkout(修正前 source)に隔離して配置し、収集後に assertion failure となること、修正後に PASS することを PR 本文に記録する(ファイル不在による pytest exit 4/5 を修正前不具合の証拠にしない)。
  • AC5: steps/step-4-pr-review.md の取得元・command を実際の producer 出力に合わせる。--artifact-dir の envelope、producer exit code の取得と --producer-exit-code / --repo の渡し方、dry_run_would_post の exit 20 と human_judgment の exit 20 の区別、existing_go(nested null)の扱い、前置 normalizer 禁止を記載し、root が手編集なしで current binding の gate に進める手順にする。

Verification Commands

# AC3
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q

# AC1
# AC2
# AC3
# AC4
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q

# AC5
# baseline-expect: fail
$ rg -n "producer-exit-code" .claude/skills/impl-review-loop/steps/step-4-pr-review.md
$ rg -n "existing_go" .claude/skills/impl-review-loop/steps/step-4-pr-review.md
$ rg -n "dry_run_would_post" .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • 新規 integration test は baseline で未作成のため pr_review_only とし、実装後に current head で独立実行して結果を canonical consumer へ渡す(実行の省略ではない)。
  • AC4 の修正前比較は VC ではなく PR 本文の証跡で確認する(base checkout に新規テストのみ配置して実行)。

Allowed Paths

  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • .claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py(step4-adjudicate の optional 引数 --producer-exit-code / --repo と入力処理)
  • .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py(新規)
  • .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py(既存回帰を追加する場合)

Stop Conditions

Required Skills

なし

Required Design References

  • docs/dev/workflow.md
  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py

Scope Delta(任意)

N/A

Delivery Rule

1 Issue = 1 PR。発見元の PR #2990 は merged 済みであり、本 Issue はそれとは分離した独立修正として扱う。

Activity

  1. added
    enhancement
    on Oct 8, 2026
  2. squne121 commented on Oct 9, 2026

    @squne121
    OwnerAuthor

    Issue #2996 敵対的レビュー

    判定:REQUEST_CHANGES。問題の切り分けは正しいですが、現状の契約では「schema 名の不整合を直したのに正常経路が依然として止まる」修正になり得ます。

    ensure_contract_snapshot.py が保存する artifact は envelope 全体であり、adjudicator の受理 schema と一致しません。この根本原因は current source でも確認できました。ただし、修正対象は JSON の内側を取り出す操作だけではなく、producer の終了コード、source 別の結果形式、後段の binding、失敗時の既存 PASS の扱いまでを含む handoff です。

    確認した repository 基準は main 6303367c0a31aeb943d9f7a6ebc4f6b596f8aa7a。Issue #2996 は OPEN、コメントはありません。発見元の PR #2990 は既に merged です。以下は、その時点の Issue 契約に対するレビューであり、#2996 の未提示の実装をレビュー済みという意味ではありません。

    1. P1:Verification Commands が正規 parser に受理されず、修正着手前の契約検証で止まる

    対象:Issue 本文の Verification Commands

    現在の二つのコマンドには、$ 接頭辞も # AC<N> の対応付けもありません。一方、repository の canonical VC grammar は bash fence 内のコマンドに $ を要求しています。既存の consumer compatibility test でも、non-dollar command は通常実行経路で VC004_NON_DOLLAR_COMMAND、status: blocked、実行結果空として扱われています。これは見栄えの問題ではなく、VC producer がコマンドとして処理する前提との不一致です。

    さらに、接頭辞だけを直しても baseline の扱いが残ります。

    既存 regression suite が baseline で成功するなら、baseline-expect: pass が必要です。現行 DoR では、annotation なしの exit 0 は unexpected_pass として blocked になります。一方、新規追加予定の test_step4_contract_snapshot_handoff.py を、まだファイルのない baseline に直接指定する方法では、実装不具合によるテスト失敗を証明できません。pytest の実装は、指定されたパスが存在しない場合に UsageError を発生させます。exit 4 は usage error、exit 5 は未収集であり、いずれも assertion による red とは別物です。 pytest ドキュメント

    影響: この handoff 修正とは無関係な VC 記法・baseline 分類で workflow が停止します。あるいは、ファイル不在を「修正前の不具合を再現した証拠」と誤認します。

    最小修正: 既存の grammar に本文を合わせ、既存回帰と新規 integration test の baseline 方針を分けてください。新規ファイルについては、baseline では pr_review_only とし、実装後の独立検証を必須にする案が扱いやすいです。別途、修正前比較では新しいテストを隔離した base checkout に配置し、収集後の assertion failure → 修正後 PASS を確認してください。checker 自体を緩めたり、新しい gate を追加したりする必要はありません。

    2. P1:AC1 の正常な dry-run が exit 20 を返す点を、canonical handoff が定義していない

    対象:AC1、Proposed Minimal Fix、Step 4 のコマンド契約

    ここは実装時に特に見落としやすい点です。現在の producer は、投稿していない正常な候補生成について次を返します。

    status: dry_run_would_post
    source: materialized_go
    contract_review_once_result.status: go
    contract_snapshot_url: null

    そして CLI は artifact を保存した後、dry_run_would_post に対して exit 20 を返します。同じ exit 20 は human_judgment にも使われています。したがって、「materialized go を生成できた」ことと「producer CLI が exit 0 で終わった」ことは一致しません。

    このため、実装者が通常の成功時チェーンとして次の構造を作ると、AC1 の正常系でも handoff に到達しません。

    ensure --mode dry-run
        └─ exit 20
             └─ 「exit 0 の場合だけ normalizer を実行」では先へ進まない

    逆に、exit 20 を一律に成功扱いする修正では、本当の human_judgment まで同じ扱いにする危険があります。Issue は source/status の検査に言及していますが、CLI の終了コードと JSON の状態をどう組み合わせて継続するかが受け入れ条件に落ちていません。

    最小修正: AC1 に次を明記するべきです。

    public CLI が dry_run_would_post / materialized_go と exit 20 を返した場合も、documented handoff がその状態を識別して候補を検証し、適合する baseline evidence と独立 current-head evidence が揃えば step4-adjudicate に到達する。human_judgment の exit 20 は同じ扱いにしない。

    これは producer の exit code を変更する提案ではありません。既存の戻り値を正しく消費する修正です。また、dry-run 候補を「投稿済み trusted snapshot」や実装開始の承認に昇格させる必要もありません。

    3. P1:existing_go の正常な null と、不正な null を区別する契約が不足している

    対象:AC2、normalizer の責務、trusted comment の取得経路

    Proposed Minimal Fix が「既存 snapshot を取得する」としている方向は正しいです。ただし、AC2 の「null nested result は gate を開かない」という記述は、source による条件を付ける必要があります。

    現在の ensure_contract_snapshot() は、baseline モードで有効な既存 snapshot を見つけると、次を返して早期終了します。

    status: ok
    source: existing_go
    contract_snapshot_url: <既存コメント>
    contract_review_once_result: null

    contract_review_once_result は初期値が None であり、この正常経路では review producer 自体を再実行しません。したがって、nested result の非 null を全 source 共通の条件にすると、正常な再利用経路を拒否します。

    さらに、取得したコメントも、そのまま adjudicator に渡せる JSON object ではありません。現行 publisher の形式は YAML の CONTRACT_REVIEW_RESULT_V1: wrapper で、classification は JSON を格納した single-quoted scalar として運ばれます。共有 parser がこの transport を decode し、block、inner、comment identity、trust 情報を持つ解析結果にしています。コメント本文を独自に YAML decode するだけ、または .inner を取り出すだけで、受理 schema まで整うとは限りません。

    もう一つ重要なのは、normalization の適用位置です。_normalize_list_payload() は classification 配列を取り出す関数ですが、後段は元の contract_snapshot からも値を読みます。

    後段の処理 | 直接参照する値 -- | -- _extract_source_integrity() | contract_snapshot.body_sha256 scoped VC の _current_head_binding_error() | contract_snapshot.status == "go"、body_sha256 evaluate_step4_vc_gate() | adjudication 内の body digest と live expected digest

    command hashes は集合一致ではなく、現行 gate が比較している順序付きリストのまま維持してください。

    VC は、既存回帰が baseline で PASS することを実測したうえで、例えば次の形に整理できます。

    # AC3
    # baseline-expect: pass
    $ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q
    

    AC1

    AC2

    AC3

    AC4

    preflight-scope: pr_review_only

    $ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q

    後者の baseline defer は、実装後の実行を省略する指示ではありません。新規 integration test を独立した current-head 検証で実行し、その結果を canonical consumer に渡す前提です。

    関連 Issue との境界

    #3004 の自己投稿直後の updatedAt false-stale は、#2996 に混ぜない方針を維持すべきです。 #3004 は publication 後の readback/race を所有し、#2996 は envelope と consumer の handoff を所有すると明記されています。#2996 側は failure envelope を勝手に成功へ変換しない一方で、race 解決のための新しい retry・publication mechanism までは抱えないのが妥当です。

    また、Issue の Delivery Rule にある「現在の #2990 の reviewer iteration を継続する」は、#2990 が merged のため現在の作業指示としては古くなっています。「発見元 PR とは分離した独立修正」とする歴史的な説明へ整理すれば十分です。

    総括: この Issue は進める価値があります。ただし、受け入れ条件を「unsupported_schema が消えた」ではなく、正常な dry-run と既存 snapshot 再利用が一度で接続され、失敗後に古い PASS が復活しないところまで固定してください。追加の承認レイヤーではなく、既存 producer/consumer の境界を正しく接続する修正が必要です。

    調査では live GitHub の本文・コメント・関連 Issue/PR・固定 SHA のコードと、pytest の実装、jq・GitHub CLI の公式資料を確認しました。repository の pytest suite と実 Claude Code session は今回再実行していません。上記の具体的な戻り値・分岐は source 確認に基づき、想定する回帰経路はその旨を区別しています。GitHub への投稿・本文変更・コード変更は行っていません。

    # Issue #2996 敵対的レビュー

    判定:REQUEST_CHANGES。問題の切り分けは正しいですが、現状の契約では「schema 名の不整合を直したのに正常経路が依然として止まる」修正になり得ます。

    ensure_contract_snapshot.py が保存する artifact は envelope 全体であり、adjudicator の受理 schema と一致しません。この根本原因は current source でも確認できました。ただし、修正対象は JSON の内側を取り出す操作だけではなく、producer の終了コード、source 別の結果形式、後段の binding、失敗時の既存 PASS の扱いまでを含む handoff です。

    確認した repository 基準は main 6303367c0a31aeb943d9f7a6ebc4f6b596f8aa7a。Issue #2996 は OPEN、コメントはありません。発見元の PR #2990 は既に merged です。以下は、その時点の Issue 契約に対するレビューであり、#2996 の未提示の実装をレビュー済みという意味ではありません。

    1. P1:Verification Commands が正規 parser に受理されず、修正着手前の契約検証で止まる

    対象:Issue 本文の Verification Commands

    現在の二つのコマンドには、$ 接頭辞も # AC<N> の対応付けもありません。一方、repository の canonical VC grammar は bash fence 内のコマンドに $ を要求しています。既存の consumer compatibility test でも、non-dollar command は通常実行経路で VC004_NON_DOLLAR_COMMAND、status: blocked、実行結果空として扱われています。これは見栄えの問題ではなく、VC producer がコマンドとして処理する前提との不一致です。

    さらに、接頭辞だけを直しても baseline の扱いが残ります。

    既存 regression suite が baseline で成功するなら、baseline-expect: pass が必要です。現行 DoR では、annotation なしの exit 0 は unexpected_pass として blocked になります。一方、新規追加予定の test_step4_contract_snapshot_handoff.py を、まだファイルのない baseline に直接指定する方法では、実装不具合によるテスト失敗を証明できません。pytest の実装は、指定されたパスが存在しない場合に UsageError を発生させます。exit 4 は usage error、exit 5 は未収集であり、いずれも assertion による red とは別物です。 [pytest ドキュメント](https://docs.pytest.org/en/stable/_modules/_pytest/main.html)

    影響: この handoff 修正とは無関係な VC 記法・baseline 分類で workflow が停止します。あるいは、ファイル不在を「修正前の不具合を再現した証拠」と誤認します。

    最小修正: 既存の grammar に本文を合わせ、既存回帰と新規 integration test の baseline 方針を分けてください。新規ファイルについては、baseline では pr_review_only とし、実装後の独立検証を必須にする案が扱いやすいです。別途、修正前比較では新しいテストを隔離した base checkout に配置し、収集後の assertion failure → 修正後 PASS を確認してください。checker 自体を緩めたり、新しい gate を追加したりする必要はありません。

    2. P1:AC1 の正常な dry-run が exit 20 を返す点を、canonical handoff が定義していない

    対象:AC1、Proposed Minimal Fix、Step 4 のコマンド契約

    ここは実装時に特に見落としやすい点です。現在の producer は、投稿していない正常な候補生成について次を返します。

    status: dry_run_would_post
    source: materialized_go
    contract_review_once_result.status: go
    contract_snapshot_url: null
    

    そして CLI は artifact を保存した後、dry_run_would_post に対して exit 20 を返します。同じ exit 20 は human_judgment にも使われています。したがって、「materialized go を生成できた」ことと「producer CLI が exit 0 で終わった」ことは一致しません。

    このため、実装者が通常の成功時チェーンとして次の構造を作ると、AC1 の正常系でも handoff に到達しません。

    ensure --mode dry-run
        └─ exit 20
             └─ 「exit 0 の場合だけ normalizer を実行」では先へ進まない
    

    逆に、exit 20 を一律に成功扱いする修正では、本当の human_judgment まで同じ扱いにする危険があります。Issue は source/status の検査に言及していますが、CLI の終了コードと JSON の状態をどう組み合わせて継続するかが受け入れ条件に落ちていません。

    最小修正: AC1 に次を明記するべきです。

    public CLI が dry_run_would_post / materialized_go と exit 20 を返した場合も、documented handoff がその状態を識別して候補を検証し、適合する baseline evidence と独立 current-head evidence が揃えば step4-adjudicate に到達する。human_judgment の exit 20 は同じ扱いにしない。

    これは producer の exit code を変更する提案ではありません。既存の戻り値を正しく消費する修正です。また、dry-run 候補を「投稿済み trusted snapshot」や実装開始の承認に昇格させる必要もありません。

    3. P1:existing_go の正常な null と、不正な null を区別する契約が不足している

    対象:AC2、normalizer の責務、trusted comment の取得経路

    Proposed Minimal Fix が「既存 snapshot を取得する」としている方向は正しいです。ただし、AC2 の「null nested result は gate を開かない」という記述は、source による条件を付ける必要があります。

    現在の ensure_contract_snapshot() は、baseline モードで有効な既存 snapshot を見つけると、次を返して早期終了します。

    status: ok
    source: existing_go
    contract_snapshot_url: <既存コメント>
    contract_review_once_result: null
    

    contract_review_once_result は初期値が None であり、この正常経路では review producer 自体を再実行しません。したがって、nested result の非 null を全 source 共通の条件にすると、正常な再利用経路を拒否します。

    さらに、取得したコメントも、そのまま adjudicator に渡せる JSON object ではありません。現行 publisher の形式は YAML の CONTRACT_REVIEW_RESULT_V1: wrapper で、classification は JSON を格納した single-quoted scalar として運ばれます。共有 parser がこの transport を decode し、block、inner、comment identity、trust 情報を持つ解析結果にしています。コメント本文を独自に YAML decode するだけ、または .inner を取り出すだけで、受理 schema まで整うとは限りません。

    もう一つ重要なのは、normalization の適用位置です。_normalize_list_payload() は classification 配列を取り出す関数ですが、後段は元の contract_snapshot からも値を読みます。

    後段の処理 直接参照する値
    _extract_source_integrity() contract_snapshot.body_sha256
    scoped VC の _current_head_binding_error() contract_snapshot.status == "go"、body_sha256
    evaluate_step4_vc_gate() adjudication 内の body digest と live expected digest

    したがって、_normalize_list_payload() 内だけで envelope を unwrap する修正では、unsupported_schema が消えても、body binding 欠落や contract_not_go によって gate が閉じたままになり得ます。

    最小修正: source 別に入力を解決した後、snapshot 全体を一度だけ正規化し、その同じ object を classification・source integrity・binding 検査へ渡す構成を推奨します。

    materialized_go では必要な nested result の null を拒否し、existing_go では envelope の nested null は正常と扱って、参照先 snapshot の取得・解析・検証失敗を拒否する、と AC2 を明確にしてください。trust、comment 選択、fingerprint、JSON scalar の処理は既存 parser/helper を再利用し、別実装を増やさない方針が適切です。

    なお、手動回避で使われた通常の jq '.contract_review_once_result' は、結果が null でも通常は exit 0 です。jq -e はこの区別には役立ちますが、source・schema・body binding の検証を代替しません。jq -e の追加だけで解決済みにしないことが必要です。[JqLang](https://jqlang.org/manual/)

    4. P1:外部 normalizer の早期失敗で、既存 PASS の失効を迂回する経路が AC にない

    対象:Proposed Minimal Fix 2、AC3・AC4

    これは #2996 の実装済み不具合という断定ではなく、現契約で防止が固定されていない回帰経路です。

    関連 Issue #2837 は、同じ binding に対する再検証が失敗した後も、以前の PASS が保存されたまま再利用される問題を扱っています。現在の step4_persist_vc_adjudication() は、新しい結果が gate を開かなければ、caller が指定した同一 binding の既存 entry を削除します。一方、--reuse-stored の経路は保存済み entry を評価します。

    そのため、独立した extract command を前置して、失敗時に step4-adjudicate を呼ばず終了する構造では、次の系列を考慮する必要があります。

    同一 binding K の PASS が保存済み
      → 新たな adjudication のため snapshot handoff を実行
      → normalizer が失敗
      → step4-adjudicate / 既存の失効処理に到達しない
      → 後続の --reuse-stored が古い K の PASS を参照できる
    

    単発の「不正 envelope では reviewer を起動しなかった」というテストだけでは、後続 invocation に残る state を検証できません。

    最小修正: 原則として、正規化を既存 step4-adjudicate の入力処理に組み込み、新しい adjudication の失敗を既存の失効経路へ流す構成を推奨します。別の state writer、ledger、gate は不要です。

    AC4 には、少なくとも次の逐次テストを追加すべきです。

    正規経路で PASS 保存 → 同一 binding の新たな adjudication で handoff 失敗 → 当該 PASS が再利用不能 → 無関係な binding は維持。再検証がない通常の --reuse-stored は従来どおり利用可能。

    ただし、単なる advisory snapshot の取得警告まで、全 PASS の失効や恒久停止に拡張しないことも重要です。current Skill は snapshot などを advisory artifact と位置付けています。対象は、あくまで新しい canonical adjudication を行う経路での失敗処理です。

    5. P2:AC4 の integration test は、実 CLI と保存 artifact を通すところまで固定したい

    現在の test_ensure_contract_snapshot.py は、既存シナリオ向けの autouse fixture で authority postcondition、publisher binding、PATCH などを成功に置き換えています。これは単体テストとしては意図された分離ですが、その suite が PASS するだけでは、今回の transport・CLI 終了コード・trusted comment round-trip の接続を証明できません。

    修正対象は既存テストの全面改変ではなく、新規の限定 integration test の境界です。 AC4 に次を明記することを推奨します。

    検証対象 必要な観測
    dry-run artifact producer CLI の実 exit code と、実際に保存された JSON を使う
    existing_go nested null の正常 envelope から、共有 parser を経て snapshot を解決する
    consumer schema 受理だけでなく、step4-adjudicate の exit code、invoke_pr_reviewer、保存された binding を確認する
    negative / recovery outer failure に inner go が残る場合、body 不一致、malformed、前項の PASS 失効を確認する
    scoped VC 通常 VC に加え、pr_review_only / runtime_only の既存 binding を緩めていないことを確認する

    GitHub のネットワーク境界は deterministic fake で構いません。今回確認した範囲では、実 Claude Code session、proxy 更新、追加の認証 receipt をこの修正の常設 gate にする必要性は見当たりません。関連 #2837 も、repository-owned script・文書・subprocess integration test で検証する範囲を定めています。

    推奨する契約修正

    修正の中心は「既存 consumer 内の source-aware な入力正規化+Step 4 文書+限定 integration regression」のままでよいと判断します。producer の published schema 変更や、汎用 wrapper の新設に広げる必要はありません。

    AC は次の到達点まで具体化すると、実装者による解釈差を抑えられます。

    AC 補強する内容
    AC1 dry-run の exit 20 を含む documented handoff が実 CLI で通り、適合 evidence では最終的に invoke_pr_reviewer: true になる
    AC2 source 別に null の意味を分離する。existing_go は参照先を再利用し、materialized 経路の不正な null や outer failure を成功へ変換しない
    AC3 正規化済み snapshot 全体を後段で共有し、head・body・宣言順の command hashes・独立実行証跡を維持する
    AC4 public CLI、保存 artifact、comment parser、stateful invalidation を接続し、修正前の assertion failure と修正後 PASS を示す

    command hashes は集合一致ではなく、現行 gate が比較している順序付きリストのまま維持してください。

    VC は、既存回帰が baseline で PASS することを実測したうえで、例えば次の形に整理できます。

    # AC3
    # baseline-expect: pass
    $ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q
    
    # AC1
    # AC2
    # AC3
    # AC4
    # preflight-scope: pr_review_only
    $ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q

    後者の baseline defer は、実装後の実行を省略する指示ではありません。新規 integration test を独立した current-head 検証で実行し、その結果を canonical consumer に渡す前提です。

    関連 Issue との境界

    #3004 の自己投稿直後の updatedAt false-stale は、#2996 に混ぜない方針を維持すべきです。 #3004 は publication 後の readback/race を所有し、#2996 は envelope と consumer の handoff を所有すると明記されています。#2996 側は failure envelope を勝手に成功へ変換しない一方で、race 解決のための新しい retry・publication mechanism までは抱えないのが妥当です。

    また、Issue の Delivery Rule にある「現在の #2990 の reviewer iteration を継続する」は、#2990 が merged のため現在の作業指示としては古くなっています。「発見元 PR とは分離した独立修正」とする歴史的な説明へ整理すれば十分です。

    総括: この Issue は進める価値があります。ただし、受け入れ条件を「unsupported_schema が消えた」ではなく、正常な dry-run と既存 snapshot 再利用が一度で接続され、失敗後に古い PASS が復活しないところまで固定してください。追加の承認レイヤーではなく、既存 producer/consumer の境界を正しく接続する修正が必要です。

    調査では live GitHub の本文・コメント・関連 Issue/PR・固定 SHA のコードと、pytest の実装、jq・GitHub CLI の公式資料を確認しました。repository の pytest suite と実 Claude Code session は今回再実行していません。上記の具体的な戻り値・分岐は source 確認に基づき、想定する回帰経路はその旨を区別しています。GitHub への投稿・本文変更・コード変更は行っていません。

  3. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    推奨方針

    Issue [#2996](#2996) に対しては、指定 OWNER コメントの5つの指摘を Issue contract に反映し、issue-refinement-loop の最終承認まで自律実行する方針を推奨します。

    確認した重要事項は次のとおりです。

    • P1 — VC 契約: $ 接頭辞、AC 対応、baseline 分類を修正する。新規テストのファイル不在を baseline RED と誤認しない。
    • P1 — dry-run: exit 20 を一律エラーにも成功にもせず、dry_run_would_post と human_judgment を区別する。
    • P1 — snapshot: materialized_go と existing_go の null の意味を区別し、snapshot 全体の正規化と downstream binding を固定する。
    • P1 — state: handoff 失敗後に、同一 binding の古い PASS が再利用されないことを検証対象にする。
    • P2 — integration: 実 CLI、artifact、trusted comment parser、adjudication と保存状態まで接続して検証する。

    今回は Issue 精緻化が対象です。実装 PR 作成やコード修正を先行させず、Issue 本文の controlled update、再レビュー、readiness 検証までを実行させます。

    別 Issue [#3004](#3004) が updatedAt の false-stale 問題を所有しています。#2996 の修正に混ぜない方針が適切です。

    Claude Code に貼り付ける実行プロンプト

    Issue #2996 — issue-refinement-loop 自律実行指示

    対象

    既に auto mode で稼働している対話的 Claude Code セッションを継続して実行する。Claude Code を再起動せず、permission mode を変更しない。

    目的は、指定コメントの REQUEST_CHANGES を #2996 の Issue contract に反映し、canonical issue-refinement-loop を最終 approved termination まで自律実行すること。

    計画・調査・提案のみで終了しない。必要な GitHub Issue 本文更新、検証、再レビュー、修復反復、終了報告、独立した再発防止 Issue の起票まで実行する。

    1. 明示的な実行承認

    この指示を、以下の作業に対する operator approval とする。

    • 指定 OWNER コメントを operator_asserted_human_context として canonical human-context lane へ渡す。
    • 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の本文、AC、VC、baseline annotations、Allowed Paths の必要最小限の整合修正を実施する。
    • canonical controlled transaction による Issue 本文更新、必要なコメント投稿、readback を実施する。
    • 必要な SubAgent、pytest、repository-native checker、外部一次資料調査を実行する。
    • needs-fix、通常の readiness failure、修正可能な VC failure に対して、人間の都度承認を求めず自動修復・再検証する。
    • semantic review と deterministic review を必要な回数だけ繰り返す。
    • max_iterations=5 を上限として許可する。現在の runtime contract と照合し、rewrite 内部の別上限は canonical router に従う。
    • 独立して再発しそうな defect を実証した場合、重複を確認して GitHub Issue を起票する。

    以上は repository workflow 内の実行承認であり、bypassPermissions、permission hook の迂回、credential 操作を許可するものではない。

    承認済み作業に対する追加の計画承認は不要。停止境界に該当しない通常の失敗では、修復と継続を優先する。

    2. Fresh state と canonical Skill の確認

    最初に以下を実施する。

    1. 現在の repository、canonical main root、default branch、worktree、dirty state を確認する。他タスクの worktree や変更を破壊しない。
    2. GitHub から Issue 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の最新本文、全コメント、指定 comment ID 6080647232 を取得する。
    3. コメントの所属、投稿者、trust metadata、最新 Issue body SHA を確認する。
    4. 実装: 再発防止: 独立 VC の正規消費経路を Step 2 / 4 / 5 に接続し、検証未了・失効後の approved を防ぐ #2837、実装: 再発防止 — contract snapshot 自己投稿直後の updatedAt 時差による false-stale を防ぐ #3004、発見元 PR fix: post-merge cleanup の guard / executor が canonical primary root を Git identity から選択する #2990、および関連する source/tests/docs の最新状態を調査する。
    5. current HEAD の CLAUDE.md、issue-refinement-loop/SKILL.md、references/anchor-comment-handling.md、references/termination-policy.md、references/ac-vc-reflection.md、references/follow-up-materialization.md と command registry を読む。
    6. 必要な SubAgent の current .claude/agents/*.md と preloaded Skill contract を確認する。

    指定コメントには HTML/Markdown の重複表現が含まれる可能性がある。同一 comment snapshot を二件の独立した要求として扱わない。

    過去ログに書かれた commit、schema、command、判定を current authority にしない。

    3. Human-context preflight と更新経路

    今回、ユーザーは指定コメントを明示的に選択し、その反映を承認している。

    したがって、canonical main root / default branch から、current registry に従って preflight.run.with_human_context を実行する。

    対象引数は次のとおり。

    • --issue-number 2996
    • --repo squne121/loop-protocol
    • --anchor-comment-url https://github.com/squne121/loop-protocol/issues/2996#issuecomment-6080647232

    STATUS、NEXT_ACTION、COMMANDS_JSON、MUST_READ、ARTIFACT、planner decision を実際に取得し、producer が返した route に従う。

    trusted contract patch plan が成立した場合は、canonical contract_update.run.with_human_context を使う。調査 evidence manifest が必要なら、read-only preflight と mutation phase で同一の manifest を再利用する。

    NEXT_ACTION: issue_editor_required の場合は、同じ mutation phase を再実行しない。指定 anchor URL を reviewer_feedback_url として既存 issue-editor / edit-issue 経路へ渡す。

    raw comment snapshot の直接転送、手組み patch payload、raw gh issue edit、controlled transaction の迂回は禁止する。

    4. Issue contract へ反映する修正

    対象コメントの全 findings を現在の repository source で fact-check し、以下を反映する。

    A. Verification Commands

    • $ 接頭辞と AC 対応を canonical VC grammar に合わせる。
    • 既存 suite は baseline の実結果を確認し、PASS なら baseline-expect: pass を指定する。
    • 新規 test_step4_contract_snapshot_handoff.py は必要に応じて preflight-scope: pr_review_only とする。
    • 存在しないテストファイルによる pytest exit 4/5 を、実装不具合の assertion RED と誤分類しない。
    • 修正前の実 failure class は、収集可能なテストを base checkout で実行して assertion failure として検証する契約を残す。
    • 実装後の新規 integration regression を必須にする。

    B. dry-run の exit 20

    AC1 に次の区別を明示する。

    • dry_run_would_post / materialized_go / nested go の exit 20 は、適合する候補 evidence の handoff を妨げない。
    • human_judgment の exit 20 は成功扱いしない。
    • CLI exit code と JSON status/source の双方で判断する。
    • dry-run 候補を投稿済み trusted snapshot または implementation authorization と同一視しない。

    C. source-aware snapshot normalization

    AC2/AC3 を補強する。

    • materialized_go: nested result の存在、schema、status、binding を検証する。
    • existing_go: 正常な nested null を認め、参照先 trusted snapshot を取得・検証する。
    • trusted comment の解析では既存 shared parser と trust/fingerprint 検証を再利用する。
    • snapshot 全体を一度正規化し、その同じ object を classification、source integrity、current-head binding に使用する。
    • body SHA、head/base binding、宣言順の command hashes、独立 VC evidence を維持する。
    • outer failure、malformed envelope、stale body、無効な trusted source は gate を開かない。

    jq による単純な内側抽出や _normalize_list_payload() の局所変更のみで解決済みとしない。

    D. 既存 PASS の失効

    AC4 に stateful sequential regression を加える。

    同一 binding に PASS 保存 → 新たな canonical adjudication の handoff 失敗 → 旧 PASS が再利用不能 → 無関係な binding は保持、という系列を検証する。

    新しい adjudication が始まっていない通常の --reuse-stored は従来どおり維持する。

    別の ledger、state writer、approval gate は追加せず、既存 consumer の失効処理を再利用する。

    E. integration regression

    AC4 の検証対象を以下まで具体化する。

    • public producer CLI の exit code
    • 保存された実 artifact
    • existing_go と shared trusted comment parser
    • step4-adjudicate の実 exit code、reviewer invocation decision、保存 binding
    • outer failure、inner go、body mismatch、malformed input
    • pr_review_only / runtime_only の既存 binding
    • PASS 保存・失効・再利用の複数 invocation

    必要十分な deterministic fake GitHub boundary と subprocess integration test を認める。実ネットワークや Claude Code session を恒久的な検証 gate にしない。

    F. Scope と Delivery Rule

    5. SubAgent の使用と completion join

    canonical planner の required decision に従って SubAgent を利用する。

    • codebase-investigator: repository source・関連 Issue/PR・技術的指摘の fact-check。read-only。
    • web-researcher: 外部仕様の確認が planner により required とされた場合のみ実行。
    • issue-editor: Issue contract の semantic rewrite が必要な場合に実行し、controlled transaction による更新まで担当する。
    • issue-creator: 独立した再発防止 follow-up の新規起票が必要な場合に使用する。

    各 SubAgent には、task、target、authority、constraints、expected output、必要な evidence を明示する。親スレッドの暗黙 context に依存させない。

    SubAgent は dispatch しただけで完了としない。必ず terminal completion を待ち、最終 result/artifact を取得・検証してから次の依存ステップへ進む。

    独立した調査は並列化してよいが、Step 2 review は必要な investigation の join 後に実行する。

    Step 2 の canonical review は root_review_pipeline.produce を main thread が run_in_background: true で起動し、task completion notification と最終 JSON を join する。canonical_step2_route を唯一の routing authority として使用する。legacy issue-reviewer SubAgent を canonical review の代替にしない。

    Step 2.5 の semantic review、Step 4 の rewrite、final review/readback、Step 4.5/5 の順序を守る。

    6. 自動修復と再検証

    Issue 本文更新後は、GitHub から独立 readback し、変更後 body SHA を固定する。

    次に fresh preflight、canonical Step 2 review、必要な Step 2.5 semantic review、readiness、contract review を実行する。

    needs-fix なら findings を issue-editor に渡して本文を修正し、再度 fresh evidence で検証する。修正後に古い APPROVE や古い body SHA の artifact を再利用しない。

    deterministic repair action が提示された場合は、current Skill/registry の正式 consumer を用い、mutation outcome・phase・failure code を確認する。

    unknown、integrity failure、真の human judgment、policy boundary、canonical 上限超過を成功に変換しない。hard stop 以外の通常の修正可能な失敗は自律的に解消する。

    最終承認には current body に対する reviewer approval、CONTRACT_REVIEW_RESULT_V1.status == go、freshness と必要な terminal gate を要求する。

    7. 再発防止 Issue

    refinement 中に新しい独立 defect を発見したら、既存 Issue と dedupe_key を検索する。

    特に #2996、#2837、#3004 が所有する問題を二重起票しない。

    既存 Issue が所有しない具体的な recurrence class が確認された場合は、canonical issue-creator / create-issue を使って新規 Issue を実際に起票する。

    Issue には root cause、再現 evidence、impact、最小修正、AC、VC、Allowed Paths、関連 Issue、dedupe_key を含める。

    起票した SubAgent の terminal result と GitHub readback を取得し、実際の Issue URL を最終報告へ記録する。

    8. 完了条件

    最終的に以下まで到達する。

    1. 指定 OWNER コメントの findings が Issue 本文に反映されている。
    2. AC/VC が canonical grammar と baseline policy に適合する。
    3. Issue body 更新の GitHub readback が成功している。
    4. fresh review と readiness / contract final gate が成功している。
    5. issue-refinement-loop の canonical approved termination が投稿されている。
    6. 必要な follow-up Issue が起票または既存 Issue へ dedupe されている。
    7. 全 SubAgent と background task の terminal completion を確認済みである。

    approved に到達しても impl-review-loop を自動開始しない。production code、実装 PR、merge、auto-merge、post-merge cleanup は今回の対象外。

    最後に、更新内容、Issue body SHA、AC/VC 結果、review iteration、SubAgent 完了状況、発見した defect、起票した Issue URL、残 blocker、最終 termination status を日本語で報告する。

    承認済みの通常作業について途中で人間へ判断を戻さず、canonical workflow の terminal outcome まで実行する。

    再発防止 Issue の判断

    既存の [#2837](#2837) は独立 VC の失効・再利用問題を扱っており、[ #3004](#3004) は publication race を扱っています。今回の5つの指摘は #2996 の契約改善で対応できる範囲と判断したため、この時点で新規 Issue は起票していません。

    代わりに、Claude Code の実調査で別の再発原因が実証された場合に、issue-creator で起票する指示を含めています。

    また、Claude Code の Auto mode は permission bypass とは異なり、実行時の安全性判定が残ります。プロンプトによってすべての権限制約を解除することはできません。今回の指示は、repository 側の通常作業に対する追加承認を不要にするものです。

    image

    Claude Code Docs

  4. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-10-10T00:31:05Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/2996
      body_sha256: "sha256:79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_mr4yywx_.md"}}
        vc_preflight:
          decision: pass
          classifications: '[{"ac":"AC3","line":3,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q","command_hash":"sha256:dd5e37afb8fdf12a4f006dd6da0c03aef6234d8f4f3e5593abf7ba7ad8609fd8","execution_key_hash":"sha256:12c254d6afd0fc1a4f7ccd549ca9a311b6c396cdbc69da41afca5e2fad7cc025","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 40%]","........................................................................ [ 80%]","...................................                                      [100%]","179 passed in 0.66s"],"stdout_truncated":false,"stdout_original_line_count":5,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":877,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: pass"},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:3f49cb2fd51608b891aa6fccd44486ddd28f180da4c7172a825a4bed33cedf18"}},{"ac":"AC1,AC2,AC3,AC4","line":10,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q","command_hash":"sha256:c3b778821bb9540b536d7fe00325edec306132d164ed0e113b774b24aed078d5","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:a3c3c724694f89ca789da0f950f9ab9d022cbfb09f416922fe54f30e8aacc4cc"}},{"ac":"AC5","line":14,"raw_command":"rg -n \"producer-exit-code\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:3fd5d33cbbede4e98c5b0aa75b74d98c49a922a610da063f8d5d96d3abf9f0b2","execution_key_hash":"sha256:d1fdadae7829d098064902f4d0a59947e33455a0c3cda9c53fc16ae315fbebd8","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":13,"raw":"# baseline-expect: fail"},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:7bdb772c1f31c54e595e516e97cbaa8c590e9fdb51ff7fe76800e56eaf07690a"}},{"ac":"AC_UNKNOWN","line":15,"raw_command":"rg -n \"existing_go\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:19416c13c841e421aeee893c7340fdb82a80f209d5deeb4e21ac24b880fae348","execution_key_hash":"sha256:d211f7a4fca2d5d469e67bd17c54db557d7f33e74ba219b17b74ab98c7916566","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:8bf718e3221b76bfd824e5e7823e3506ddc5a572da65b9ad684572531b56997f"}},{"ac":"AC_UNKNOWN","line":16,"raw_command":"rg -n \"dry_run_would_post\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:f03b78975bce7a3ee56cfbf24148c59830f0f58d8f2b11c910365b1637b22355","execution_key_hash":"sha256:7feb1aec07784f6bd588f02fd48f8961ffe49296af3473ad152a7adcde61bb6d","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":1,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:ec6939e30131fac6874bb802d1602bd44ae53ad127b7d965eb31854e30d9f893"}}]'
          classifications_transport: {"schema":"vc_preflight_classifications_transport/v1","classification_count":5,"original_payload_sha256":"sha256:f2009258040cbee6f6ce5b1824b14159037b7362cf05bae7e9d8d7d3461d6c87","compact":false,"truncated":false}
        declared_path_overlap: '{"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"2258cccf17ed631441ea8573efcca178f9ce4af9","draft_policy":"include_drafts","prs":[{"number":2831,"title":"実装: Claude-GPT model/proxy runtime migration の3分類ルーティングを追加する","base_ref_name":"main","head_ref_name":"worktree-issue-2810-runtime-migration-classifier","head_ref_oid":"7c06e272c14b2d38e8f01899abdf85f3d0d5c9ec","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2831","changed_files_count_graphql":20},{"number":2914,"title":"fix: test-runner が mergeStateStatus=BLOCKED/UNSTABLE だけで TEST_VERDICT を FAIL にしないようにする","base_ref_name":"main","head_ref_name":"worktree-issue-2908-test-runner-blocked-not-fail","head_ref_oid":"2f44329742e2117b1bbbb34452417362558175aa","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2914","changed_files_count_graphql":1},{"number":2931,"title":"fix: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped workspace で解消する","base_ref_name":"main","head_ref_name":"worktree-issue-2860-run-scoped-scratch","head_ref_oid":"344f5da35326e04dacd13aa57dd962674888f336","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2931","changed_files_count_graphql":6},{"number":2940,"title":"feat: runner evidence に main-session init の permission_mode_observed を出力する","base_ref_name":"main","head_ref_name":"worktree-issue-2935-main-session-permission-mode","head_ref_oid":"37eb1ae20b98cc72fed816a7c88aca0d9b623a39","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2940","changed_files_count_graphql":3},{"number":2946,"title":"fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941)","base_ref_name":"main","head_ref_name":"worktree-issue-2941-claude-2-1-289-causal-evidence","head_ref_oid":"0fbc32e03e377b36d5800c940ab8311479c8cf46","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2946","changed_files_count_graphql":1},{"number":2974,"title":"fix: component-vrt-report の negative-control artifact を run_attempt 単位名に束縛する (#2969)","base_ref_name":"main","head_ref_name":"worktree-issue-2969-vrt-negctl-attempt-artifact","head_ref_oid":"2ab61441acc3f5062fa83fd147f570958f2dea3e","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2974","changed_files_count_graphql":2},{"number":3001,"title":"fix: repo-local 証跡を外部 claim の Web gate から分離する","base_ref_name":"main","head_ref_name":"worktree-issue-2857-repo-local-claims","head_ref_oid":"a31ac63634e67c1b8ccf1aeed8ef8f141b0f86bd","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3001","changed_files_count_graphql":3},{"number":3003,"title":"fix: legacy termination dry-run でコメントと signal を抑止する (#2988)","base_ref_name":"main","head_ref_name":"worktree-issue-2988-termination-dry-run","head_ref_oid":"8f3e530b2f07c89a1e1260d578c523de5eae61d5","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3003","changed_files_count_graphql":2}],"fetched_count":8,"totalCount":8,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:cd872e8d93c794bf494b8f83abd4e01060dfe1610b71ab88e2a7df4382a72445","errors":[]},"inventory_digest_extended":"sha256:746772a2a1695cdc54dea01d449e6b8932cb94029acffb61ad18d89b4ce4432e","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}'
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: '{"issue_number":2996,"contract_source_kind":"issue_comment","contract_source_id":"6091639616","contract_body_sha256":"sha256:79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003","allowed_paths_normalized_sha256":"e8eb5fd234b7fcb0be3e1d4ee78ad2fb13cea9c3d0b3d55016d00fa7d9634f64","base_ref":"main","base_sha_at_snapshot":"2258cccf17ed631441ea8573efcca178f9ce4af9"}'
  5. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告: approved

    OWNER の REQUEST_CHANGES(comment 6080647232)を operator_asserted_human_context として反映し、Issue 本文を 3 回更新して approved に到達しました。

    • 最終 body SHA256: 79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003
    • review iteration: 3 回(決定論的 review は各 body で approve、semantic review は iteration 1 で high 2 件 → 本文修正、iteration 2 は medium 2 件・low 1 件 → 本文修正、iteration 3 は low 2 件のみで approve)
    • 反映内容: VC grammar と baseline 方針、dry-run の exit 20 と human_judgment の区別(--producer-exit-code)、source 別 snapshot 解決と一度きりの正規化、同一 binding の stale PASS 失効の維持、実 CLI を通す integration regression
    • 残る low 指摘(実装時の注記): AC2 は expected_issue_url を --repo と --expected-issue-number から構成し、URL の owner/repo/issue/comment id を shared parser の結果と照合する。解決処理は _run_step4_adjudicate で行い、--reuse-stored との併用時の扱いを固定する。
    LOOP_HANDOFF_RESULT_V1:
      status: refinement_approved
      routing_action: none
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/2996#issuecomment-6091639616
        generated_at: 2026-10-10T00:33:37Z
        body_sha256: sha256:79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: ラベル同期は実施していない(presentation-only metadata)
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: 2026-10-10T00:33:37Z
      checked_body_sha256: sha256:79f9463ccfceae998aeb65d042cc7d34572e46608a5acc441ac9241de7430003
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    approved は実装開始の承認ではありません。impl-review-loop は自動起動していません。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - request_dedupe_key: "impl-review-loop:ensure-contract-snapshot:exit-code-and-artifact-contract-doc-drift"
          status: created
          issue:
            number: 3005
            url: "https://github.com/squne121/loop-protocol/issues/3005"
          reason: null
      note_only_observations: []
  6. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    推奨方針

    Issue #2996 は、refinement をやり直さず、現行の impl-review-loop で実装・検証・レビュー・自動修復を行い、マージ直前まで進める方針を推奨します。

    2026年10月10日時点の GitHub を確認しました。

    項目 | 確認結果 -- | -- Issue #2996 | OPEN、実装契約が更新済み Refinement 終了コメント | refinement_approved Contract snapshot | status: go Issue body SHA-256 | 79f9463ccfce…1de7430003 再発防止 Issue #3005 | 起票済み、OPEN

    添付ログでは FACT_TASK_IDENTITY_CONFLICT により Task Context への承認シグナル適用が拒否されています。ただし、GitHub 上の終了コメントと contract snapshot は存在します。

    したがって、終了コメントだけを実装権限とみなして gate を飛ばすのではなく、fresh session で current contract review と implementation entry を正式に通すことが重要です。

    また、#2996 の最終 semantic review で残った low finding 2件は、今回の実装で解消するのが適切です。特に expected_issue_url の束縛と _run_step4_adjudicate の責務境界は、テストまで固定します。

    追加確認では、現在の OPEN PR 8件に #2996 の実装 PR は見つかりませんでした。したがって、新規 PR 作成を想定しつつ、Claude Code 側で canonical landing disposition を再評価させます。

    Claude Code に貼り付ける実行プロンプト

    Issue #2996 — impl-review-loop 自律実装・検証・レビュー

    目的と対象

    Repository: squne121/loop-protocol

    Target Issue:
    https://github.com/squne121/loop-protocol/issues/2996

    Canonical Skill:
    .claude/skills/impl-review-loop/SKILL.md

    Current refinement evidence:

    既に auto mode で起動済みの対話的 fresh Claude Code セッションを継続する。再起動・permission mode 変更は不要。

    目的は、#2996 の current implementation contract に対して canonical impl-review-loop を実行し、実装、独立検証、PR レビュー、必要な修復反復、CI 確認まで自律的に完了すること。

    最終到達点は、人間がマージ判断できる直前の PR。実 merge は行わない。

    計画・調査・提案だけで終了せず、canonical workflow の terminal outcome まで実行する。

    1. Operator approval — 明示的な実行承認

    以下の通常作業を、この指示によって事前承認する。

    • GitHub Issue、コメント、PR、main、関連 repository SSOT の取得と調査

    • current-run contract review と正式 implementation entry

    • canonical linked worktree / branch の作成、または既存資産の再利用

    • Issue 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の Allowed Paths 内の実装・修正

    • 必要な SubAgent の起動と結果回収

    • baseline regression、negative-control test、integration test の追加・実行

    • pytest、required CI、repository-native verification の実行

    • Draft PR の作成・更新、commit、push、レビューコメント投稿

    • canonical workflow が許す場合の Draft → Ready for Review

    • REQUEST_CHANGES、修正可能な test/CI failure に対する自動修復

    • 修正後の fresh HEAD での再検証・再レビュー

    • main drift 時の canonical reconciliation / update_branch

    • 再発防止 Issue の重複検索、および独立 defect が確認された場合の正式起票

    • 通常の非破壊的 GitHub metadata 操作と readback

    max_iterations=5 を本実行の希望上限とする。ただし、current Skill / runtime が受理する範囲で設定し、canonical iteration policy、no-progress 判定、hard stop は変更しない。

    通常の test failure、review finding、CI failure、stale HEAD は、それ単独では人間への再承認要求にしない。既存の修復・再実行 route へ進む。

    この承認は Claude Code の permissions bypass を意味しない。bypassPermissions、--dangerously-skip-permissions、credential 操作、policy/hook 迂回は要求しない。

    2. Fresh state の取得

    作業開始前に以下を確認する。

    1. repository identity、canonical main root、main HEAD、worktree 一覧、dirty state

    2. Issue 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の最新本文、AC1〜AC5、Verification Commands、Allowed Paths、Stop Conditions

    3. Issue コメントの最新順序と trusted CONTRACT_REVIEW_RESULT_V1

    4. current OPEN / Draft / merged PR、linked branch、closing relation、scope coverage

    5. main drift、既存実装、同一変更の先行着手状況

    6. 既存 Task Context の primary Issue identity

    次の現行資産を読む。

    • CLAUDE.md / AGENTS.md(存在する場合)

    • .claude/skills/impl-review-loop/SKILL.md

    • .claude/skills/impl-review-loop/steps/preparation.md

    • step-1-implementation.md

    • step-2-verification.md

    • step-4-pr-review.md

    • step-5-feedback-and-termination.md

    • step-5-mergeability-handling.md

    • .claude/skills/issue-refinement-loop/references/termination-policy.md

    • .claude/agents/implementation-worker.md

    • .claude/agents/test-runner.md

    • .claude/agents/pr-reviewer.md

    • 必要な implement-issue、pr-review-judge、open-pr Skill

    Skill 名、コマンド、SubAgent の存在・役割は current HEAD で確認する。過去ログの version、main SHA、command arguments を無検証で再利用しない。

    3. Root-owned implementation entry

    #2996 の refinement は GitHub 上で approved となり、trusted contract snapshot も go である。

    しかし、過去の LOOP_HANDOFF_RESULT_V1 コメントだけでは Step 1 起動権限にならない。

    current repository の Root-Owned Synchronous Entry Transition に従い、main/root thread で以下を連続実行する。

    1. capability preflight

    2. live Issue fetch

    3. current-run issue-contract-review

    4. 直後の live body / base 再取得

    5. decide_root_entry_route() の正式判断

    6. invoke_impl_review_loop のときだけ、同じ continuous turn で implementation を開始する

    現在の root_entry_router.py は CLI でも利用できるが、CLI 自体は Agent の Step 1 を起動しない。route / invoked を保存済み authorization token のように後から再利用せず、同一の継続した root execution で Step 1 に接続する。

    rerun_contract_review、rerun_base_preflight 等が返された場合は current canonical route で bounded に解消する。stop を無断で invoke に変換しない。

    前回 refinement session では、Task Context が別 Issue に束縛され FACT_TASK_IDENTITY_CONFLICT が発生した。今回も Task identity を確認し、必要なら repository-supported な正式 rebind/reconciliation を利用する。偽の workflow signal や手組み Task Context state を作らない。

    Step 1 の worker dispatch より先に evidence-based landing disposition を実行する。

    • existing_pr_resume → 既存 PR と worktree を再利用

    • implementation_already_landed / already_satisfied → canonical no-op 判断

    • ordinary_dispatch_or_explicit_recovery → 通常の新規実装

    • reconciliation_required → 最新 evidence に基づき reconciliation。重複 PR を作らない

    4. 実装要求 — AC1〜AC5

    A. Producer exit code と envelope handoff

    CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 を正規 producer の出力として扱う。

    step4-adjudicate に Issue contract どおり --producer-exit-code を追加し、envelope の場合は終了コードと JSON の status/source を照合する。

    • ok / exit 0: 許容 source を検証

    • dry_run_would_post / materialized_go / exit 20: 正常な候補 evidence として検証可能

    • human_judgment / exit 20: 拒否

    • outer blocked、runtime error、stale、binding failure、未知の組合せ: 拒否

    • exit code の欠落・不一致: fail-closed

    非 envelope snapshot と --producer-exit-code の不適切な併用は拒否する。

    producer の exit code や published schema は変更しない。

    B. Source-aware snapshot normalization

    次の3経路を実装・検証する。

    1. dry_run_would_post + materialized_go
      nested go を候補 evidence として検証する。

    2. ok + existing_go
      nested null を正常として認め、参照先 trusted comment を検証する。nested が存在しても trusted comment を authority とする。

    3. ok + materialized_go(投稿成功)
      投稿済み trusted comment を authority として検証する。

    既存 shared parser を使用し、独立した YAML parser / trust classifier を作らない。

    --repo と --expected-issue-number を正しく束縛する。

    前回 semantic review で残った low finding を今回解消するため、以下を明示的な実装・回帰対象にする。

    • expected_issue_url を caller-supplied --repo と --expected-issue-number から構成する

    • contract_snapshot_url の owner / repository / Issue number / comment ID を解析・照合する

    • URL の対象が shared parser による対象 comment と一致することを確認する

    • trusted author / fingerprint-ready / latest trusted result の既存選択規則を再利用する

    • より新しい trusted blocked result があれば、古い go を受理しない

    正規化後は、schema / status / body SHA / classifications を備えた同一 canonical snapshot object を downstream 全体で使う。

    _normalize_list_payload() の局所的な unwrap だけで済ませない。

    C. 入力処理と stale PASS invalidation

    envelope 解決の責務は _run_step4_adjudicate の入力前処理に置く方針を優先する。

    解決成功時は canonical snapshot object を既存 step4_adjudicate() に渡す。

    失敗時は partial / unresolved snapshot を渡さず、contract_snapshot=None と構造化 errors を既存 adjudication / persist 経路へ渡す。

    新たな adjudication の handoff failure でも同一 binding の古い PASS が失効することを保証する。

    --reuse-stored と --producer-exit-code / --repo の併用は、通常の stored PASS 再利用経路と混同しないよう拒否する方針で固定し、回帰テストに含める。

    ただし通常の --reuse-stored 自体は維持する。

    LOOP_STATE の手編集、独立 ledger、追加 approval gate、前置 normalizer の新規チェーンは導入しない。

    D. Binding invariants

    既存の次の条件を緩めない。

    • current PR HEAD

    • Issue body SHA-256

    • 宣言順の command hashes(順序付き比較)

    • pr_review_only / runtime_only の binding

    • TEST_VERDICT_MACHINE/v2 の独立 evidence

    • step4-adjudicate の dispatch sequence

    • step5-terminal-gate の terminal approval

    schema-supported になっただけで gate 成功とはしない。

    E. Integration regression

    新規 test_step4_contract_snapshot_handoff.py を追加する。

    単体 mock で出力形式を模倣するだけでは不十分。producer / consumer は実 CLI を subprocess として実行する。

    GitHub 境界は deterministic fake gh shim とし、必要な POST / PATCH / GET とコメント状態を保持する。

    少なくとも次を検証する。

    • public producer の実 exit code と保存 artifact

    • dry-run materialized go の正常 handoff

    • existing_go の nested null

    • 投稿成功 materialized_go の trusted comment

    • shared parser の comment selection

    • repo / Issue / comment ID の不一致

    • より新しい trusted blocked comment

    • malformed envelope、outer failure、inner go の不正受理防止

    • body SHA / command hashes / HEAD の不一致

    • step4-adjudicate exit code と invoke_pr_reviewer

    • PASS 保存 → 同一 binding の新規 handoff 失敗 → 旧 PASS 失効

    • 無関係な binding は維持

    • 通常の --reuse-stored の後方互換

    • 新引数と --reuse-stored の不適切な併用

    修正前の failure class を、修正前 source を使う独立した base checkout と新規テストによって再現する。

    pytest の test file 不在による exit 4/5 を assertion RED とみなさない。

    収集済み assertion failure と修正後 PASS の対照 evidence を PR 本文に記録する。

    既存の179件 PASSという過去結果は参考値としてのみ扱い、今回の checkout でも再実行する。

    F. Step 4 ドキュメント

    step-4-pr-review.md を実際の CLI に合わせて更新する。

    envelope の保存先、exit code の取得、--producer-exit-code / --repo、existing_go、dry-run exit 20、trusted comment selection、失敗時の invalidation 経路を記述する。

    root の手作業 jq による gate 回避を不要にする。

    5. Scope 制約

    #2996 の Allowed Paths を厳守する。

    • .claude/skills/impl-review-loop/steps/step-4-pr-review.md

    • .claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py

    • .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py

    • .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py

    以下は変更しない。

    既存の関連 Issue #3005 は exit code / artifact 文書の drift を独立して所有する。#2996 に混ぜない。

    6. SubAgent orchestration と completion join

    canonical Skill の Step ごとに、必要な SubAgent を使う。

    • implementation-worker: implementation、fix_delta、worktree / PR 更新

    • test-runner: 独立した Verification Commands と TEST_VERDICT_MACHINE/v2

    • pr-reviewer: actual PR diff / Issue AC / evidence / CI の read-only review

    • issue-creator: 重複しない独立した再発防止 defect が確認されたときだけ新規 Issue 起票

    必要な調査は適切な read-only lane へ委譲してよい。

    SubAgent の起動前に current .claude/agents/*.md の frontmatter、tools、preloaded skills、permission mode、nested delegation 制約を確認する。

    各 SubAgent には実値で以下を渡す。

    • task / target Issue・PR

    • authority と current HEAD

    • Allowed Paths / constraints

    • 必要な artifact / source evidence

    • expected result schema

    • completion criteria

    親 thread の暗黙 context に依存させない。

    SubAgent を dispatch しただけで完了扱いしない。

    canonical Common Completion Protocol に従う。

    1. dispatch した task name を記録する

    2. wait_agent / completion notification で終了を待つ

    3. final result を取得する

    4. list_agents で当該 task の terminal completed を確認する

    5. result schema・HEAD・evidence を検証する

    6. downstream dependency へ進む

    timeout、intermediate update、errored、interrupted、shutdown、not_found は成功ではない。

    独立した作業は並列実行してよい。依存する作業は必ず join 後に進める。

    7. Review / fix loop

    次のサイクルを実行する。

    inspect → implement → test → PR → current-head adjudication → PR review → fix → re-test → fresh re-review

    Step 4 では current repository の step4-adjudicate を使用する。

    • invoke_pr_reviewer: true / exit 0 の場合だけ reviewer を起動

    • exit 1 の場合は実原因を解消し、必要なら Step 2 を再実行

    • state persist failure では既存 PASS の失効未確認を成功扱いしない

    • --reuse-stored は canonical に適格な場合だけ使用

    REQUEST_CHANGES であれば findings を fix_delta として worker に渡す。修復、commit、push、テスト、CI、fresh review を反復する。

    CI failure は required check の具体的 failed log を取得して root cause を修正する。CI pending / skipped を PASS に変換しない。

    BEHIND なら正式 update_branch route、HEAD が進んだ場合は fresh review route を使う。

    step5-terminal-gate の exit 0 以外で approved を宣言しない。

    最終判定は live HEAD、current binding、stored adjudication、dispatch seq、reviewer verdict、required CI、live mergeability の組合せで行う。

    8. 再発防止 Issue

    実装中に新しい独立 defect を発見した場合、repository 内の OPEN/CLOSED Issue、PR、dedupe_key を検索する。

    既知の関連範囲:

    既存 Issue が所有する問題は二重起票しない。

    未所有の独立 defect を再現できた場合は、issue-creator / create-issue の現行正式経路で実際に GitHub Issue を起票する。

    root cause、再現 evidence、impact、最小修正、AC、VC、Allowed Paths、dedupe_key、関連 Issue を含める。

    起票後は SubAgent terminal result と GitHub readback を確認する。

    9. 停止境界

    通常の修復可能な失敗で停止しない。

    ただし次は canonical policy に従って停止または escalation する。

    • 実 Git conflict の hard stop

    • destructive / irreversible operation

    • credential / secret 操作

    • 他タスクの worktree・dirty state への侵入

    • 解消不能な authority / scope conflict

    • formal human_judgment_required

    • verified evidence integrity failure

    • canonical iteration / no-progress 上限到達

    • permissions / policy bypass が不可避

    • ユーザーの明示停止

    新規 issue の起票権限は既に承認済みだが、#2996 の write scope を自動拡張する権限ではない。

    10. 完了条件と最終報告

    次をすべて確認する。

    1. 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の AC1〜AC5 を実装

    2. Allowed Paths 遵守

    3. 実 failure → fix → PASS の regression evidence

    4. 必須 Verification Commands と required CI の fresh 結果

    5. 最新 PR HEAD での PR review

    6. 未解決の blocking finding がない

    7. step5-terminal-gate が exit 0

    8. 全 SubAgent が terminal completed

    9. GitHub PR の更新・readback が成功

    10. PR は人間がマージ判断できる状態

    11. 実 merge、auto-merge、post-merge cleanup は未実行

    日本語の最終報告には次を含める。

    • Issue / PR URL

    • base・HEAD SHA / worktree

    • 実装変更と AC 対応

    • Verification Commands と実結果

    • regression の before / after evidence

    • required CI 結果

    • review iteration と各 verdict

    • 修復履歴

    • 未解決 warning / blocker

    • 再発防止 Issue の created / reused / skipped

    • canonical terminal status

    • merge_ready の根拠

    承認済みの通常作業について人間の都度承認を求めず、canonical workflow が許す範囲で最後まで実行する。

    まず fresh repository / Issue / PR / Task Context state と current Skill を確認し、正式 entry から開始せよ。

    再発防止 Issue の扱い

    既に #3005 が起票されています。また、Task Context の identity 問題には既存の #2835 が存在します。

    今回の調査では、これらと独立した新たな defect は確定していないため、重複 Issue は追加起票していません。 実装時に新しい failure class が実証された場合のみ、プロンプト内の指示に従って起票する方針です。

    このプロンプトは、現在確認できる #2996 の契約と impl-review-loop の実行境界に合わせています。

    ## 推奨方針

    Issue #2996 は、refinement をやり直さず、現行の impl-review-loop で実装・検証・レビュー・自動修復を行い、マージ直前まで進める方針を推奨します。

    2026年10月10日時点の GitHub を確認しました。

    項目 確認結果
    [Issue #2996](#2996) OPEN、実装契約が更新済み
    [Refinement 終了コメント](#2996 (comment)) refinement_approved
    [Contract snapshot](#2996 (comment)) status: go
    Issue body SHA-256 79f9463ccfce…1de7430003
    [再発防止 Issue #3005](#3005) 起票済み、OPEN

    添付ログでは FACT_TASK_IDENTITY_CONFLICT により Task Context への承認シグナル適用が拒否されています。ただし、GitHub 上の終了コメントと contract snapshot は存在します。

    したがって、終了コメントだけを実装権限とみなして gate を飛ばすのではなく、fresh session で current contract review と implementation entry を正式に通すことが重要です。

    また、#2996 の最終 semantic review で残った low finding 2件は、今回の実装で解消するのが適切です。特に expected_issue_url の束縛と _run_step4_adjudicate の責務境界は、テストまで固定します。

    追加確認では、現在の OPEN PR 8件に #2996 の実装 PR は見つかりませんでした。したがって、新規 PR 作成を想定しつつ、Claude Code 側で canonical landing disposition を再評価させます。

    Claude Code に貼り付ける実行プロンプト

    Issue #2996 — impl-review-loop 自律実装・検証・レビュー

    目的と対象

    Repository: squne121/loop-protocol

    Target Issue:
    #2996

    Canonical Skill:
    .claude/skills/impl-review-loop/SKILL.md

    Current refinement evidence:

    既に auto mode で起動済みの対話的 fresh Claude Code セッションを継続する。再起動・permission mode 変更は不要。

    目的は、#2996 の current implementation contract に対して canonical impl-review-loop を実行し、実装、独立検証、PR レビュー、必要な修復反復、CI 確認まで自律的に完了すること。

    最終到達点は、人間がマージ判断できる直前の PR。実 merge は行わない。

    計画・調査・提案だけで終了せず、canonical workflow の terminal outcome まで実行する。

    1. Operator approval — 明示的な実行承認

    以下の通常作業を、この指示によって事前承認する。

    • GitHub Issue、コメント、PR、main、関連 repository SSOT の取得と調査
    • current-run contract review と正式 implementation entry
    • canonical linked worktree / branch の作成、または既存資産の再利用
    • Issue 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の Allowed Paths 内の実装・修正
    • 必要な SubAgent の起動と結果回収
    • baseline regression、negative-control test、integration test の追加・実行
    • pytest、required CI、repository-native verification の実行
    • Draft PR の作成・更新、commit、push、レビューコメント投稿
    • canonical workflow が許す場合の Draft → Ready for Review
    • REQUEST_CHANGES、修正可能な test/CI failure に対する自動修復
    • 修正後の fresh HEAD での再検証・再レビュー
    • main drift 時の canonical reconciliation / update_branch
    • 再発防止 Issue の重複検索、および独立 defect が確認された場合の正式起票
    • 通常の非破壊的 GitHub metadata 操作と readback

    max_iterations=5 を本実行の希望上限とする。ただし、current Skill / runtime が受理する範囲で設定し、canonical iteration policy、no-progress 判定、hard stop は変更しない。

    通常の test failure、review finding、CI failure、stale HEAD は、それ単独では人間への再承認要求にしない。既存の修復・再実行 route へ進む。

    この承認は Claude Code の permissions bypass を意味しない。bypassPermissions、--dangerously-skip-permissions、credential 操作、policy/hook 迂回は要求しない。

    2. Fresh state の取得

    作業開始前に以下を確認する。

    1. repository identity、canonical main root、main HEAD、worktree 一覧、dirty state
    2. Issue 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の最新本文、AC1〜AC5、Verification Commands、Allowed Paths、Stop Conditions
    3. Issue コメントの最新順序と trusted CONTRACT_REVIEW_RESULT_V1
    4. current OPEN / Draft / merged PR、linked branch、closing relation、scope coverage
    5. main drift、既存実装、同一変更の先行着手状況
    6. 既存 Task Context の primary Issue identity

    次の現行資産を読む。

    • CLAUDE.md / AGENTS.md(存在する場合)
    • .claude/skills/impl-review-loop/SKILL.md
    • .claude/skills/impl-review-loop/steps/preparation.md
    • step-1-implementation.md
    • step-2-verification.md
    • step-4-pr-review.md
    • step-5-feedback-and-termination.md
    • step-5-mergeability-handling.md
    • .claude/skills/issue-refinement-loop/references/termination-policy.md
    • .claude/agents/implementation-worker.md
    • .claude/agents/test-runner.md
    • .claude/agents/pr-reviewer.md
    • 必要な implement-issue、pr-review-judge、open-pr Skill

    Skill 名、コマンド、SubAgent の存在・役割は current HEAD で確認する。過去ログの version、main SHA、command arguments を無検証で再利用しない。

    3. Root-owned implementation entry

    #2996 の refinement は GitHub 上で approved となり、trusted contract snapshot も go である。

    しかし、過去の LOOP_HANDOFF_RESULT_V1 コメントだけでは Step 1 起動権限にならない。

    current repository の Root-Owned Synchronous Entry Transition に従い、main/root thread で以下を連続実行する。

    1. capability preflight
    2. live Issue fetch
    3. current-run issue-contract-review
    4. 直後の live body / base 再取得
    5. decide_root_entry_route() の正式判断
    6. invoke_impl_review_loop のときだけ、同じ continuous turn で implementation を開始する

    現在の root_entry_router.py は CLI でも利用できるが、CLI 自体は Agent の Step 1 を起動しない。route / invoked を保存済み authorization token のように後から再利用せず、同一の継続した root execution で Step 1 に接続する。

    rerun_contract_review、rerun_base_preflight 等が返された場合は current canonical route で bounded に解消する。stop を無断で invoke に変換しない。

    前回 refinement session では、Task Context が別 Issue に束縛され FACT_TASK_IDENTITY_CONFLICT が発生した。今回も Task identity を確認し、必要なら repository-supported な正式 rebind/reconciliation を利用する。偽の workflow signal や手組み Task Context state を作らない。

    Step 1 の worker dispatch より先に evidence-based landing disposition を実行する。

    • existing_pr_resume → 既存 PR と worktree を再利用
    • implementation_already_landed / already_satisfied → canonical no-op 判断
    • ordinary_dispatch_or_explicit_recovery → 通常の新規実装
    • reconciliation_required → 最新 evidence に基づき reconciliation。重複 PR を作らない

    4. 実装要求 — AC1〜AC5

    A. Producer exit code と envelope handoff

    CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 を正規 producer の出力として扱う。

    step4-adjudicate に Issue contract どおり --producer-exit-code を追加し、envelope の場合は終了コードと JSON の status/source を照合する。

    • ok / exit 0: 許容 source を検証
    • dry_run_would_post / materialized_go / exit 20: 正常な候補 evidence として検証可能
    • human_judgment / exit 20: 拒否
    • outer blocked、runtime error、stale、binding failure、未知の組合せ: 拒否
    • exit code の欠落・不一致: fail-closed

    非 envelope snapshot と --producer-exit-code の不適切な併用は拒否する。

    producer の exit code や published schema は変更しない。

    B. Source-aware snapshot normalization

    次の3経路を実装・検証する。

    1. dry_run_would_post + materialized_go
      nested go を候補 evidence として検証する。
    2. ok + existing_go
      nested null を正常として認め、参照先 trusted comment を検証する。nested が存在しても trusted comment を authority とする。
    3. ok + materialized_go(投稿成功)
      投稿済み trusted comment を authority として検証する。

    既存 shared parser を使用し、独立した YAML parser / trust classifier を作らない。

    --repo と --expected-issue-number を正しく束縛する。

    前回 semantic review で残った low finding を今回解消するため、以下を明示的な実装・回帰対象にする。

    • expected_issue_url を caller-supplied --repo と --expected-issue-number から構成する
    • contract_snapshot_url の owner / repository / Issue number / comment ID を解析・照合する
    • URL の対象が shared parser による対象 comment と一致することを確認する
    • trusted author / fingerprint-ready / latest trusted result の既存選択規則を再利用する
    • より新しい trusted blocked result があれば、古い go を受理しない

    正規化後は、schema / status / body SHA / classifications を備えた同一 canonical snapshot object を downstream 全体で使う。

    _normalize_list_payload() の局所的な unwrap だけで済ませない。

    C. 入力処理と stale PASS invalidation

    envelope 解決の責務は _run_step4_adjudicate の入力前処理に置く方針を優先する。

    解決成功時は canonical snapshot object を既存 step4_adjudicate() に渡す。

    失敗時は partial / unresolved snapshot を渡さず、contract_snapshot=None と構造化 errors を既存 adjudication / persist 経路へ渡す。

    新たな adjudication の handoff failure でも同一 binding の古い PASS が失効することを保証する。

    --reuse-stored と --producer-exit-code / --repo の併用は、通常の stored PASS 再利用経路と混同しないよう拒否する方針で固定し、回帰テストに含める。

    ただし通常の --reuse-stored 自体は維持する。

    LOOP_STATE の手編集、独立 ledger、追加 approval gate、前置 normalizer の新規チェーンは導入しない。

    D. Binding invariants

    既存の次の条件を緩めない。

    • current PR HEAD
    • Issue body SHA-256
    • 宣言順の command hashes(順序付き比較)
    • pr_review_only / runtime_only の binding
    • TEST_VERDICT_MACHINE/v2 の独立 evidence
    • step4-adjudicate の dispatch sequence
    • step5-terminal-gate の terminal approval

    schema-supported になっただけで gate 成功とはしない。

    E. Integration regression

    新規 test_step4_contract_snapshot_handoff.py を追加する。

    単体 mock で出力形式を模倣するだけでは不十分。producer / consumer は実 CLI を subprocess として実行する。

    GitHub 境界は deterministic fake gh shim とし、必要な POST / PATCH / GET とコメント状態を保持する。

    少なくとも次を検証する。

    • public producer の実 exit code と保存 artifact
    • dry-run materialized go の正常 handoff
    • existing_go の nested null
    • 投稿成功 materialized_go の trusted comment
    • shared parser の comment selection
    • repo / Issue / comment ID の不一致
    • より新しい trusted blocked comment
    • malformed envelope、outer failure、inner go の不正受理防止
    • body SHA / command hashes / HEAD の不一致
    • step4-adjudicate exit code と invoke_pr_reviewer
    • PASS 保存 → 同一 binding の新規 handoff 失敗 → 旧 PASS 失効
    • 無関係な binding は維持
    • 通常の --reuse-stored の後方互換
    • 新引数と --reuse-stored の不適切な併用

    修正前の failure class を、修正前 source を使う独立した base checkout と新規テストによって再現する。

    pytest の test file 不在による exit 4/5 を assertion RED とみなさない。

    収集済み assertion failure と修正後 PASS の対照 evidence を PR 本文に記録する。

    既存の179件 PASSという過去結果は参考値としてのみ扱い、今回の checkout でも再実行する。

    F. Step 4 ドキュメント

    step-4-pr-review.md を実際の CLI に合わせて更新する。

    envelope の保存先、exit code の取得、--producer-exit-code / --repo、existing_go、dry-run exit 20、trusted comment selection、失敗時の invalidation 経路を記述する。

    root の手作業 jq による gate 回避を不要にする。

    5. Scope 制約

    #2996 の Allowed Paths を厳守する。

    • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
    • .claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py
    • .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py
    • .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py

    以下は変更しない。

    既存の関連 Issue #3005 は exit code / artifact 文書の drift を独立して所有する。#2996 に混ぜない。

    6. SubAgent orchestration と completion join

    canonical Skill の Step ごとに、必要な SubAgent を使う。

    • implementation-worker: implementation、fix_delta、worktree / PR 更新
    • test-runner: 独立した Verification Commands と TEST_VERDICT_MACHINE/v2
    • pr-reviewer: actual PR diff / Issue AC / evidence / CI の read-only review
    • issue-creator: 重複しない独立した再発防止 defect が確認されたときだけ新規 Issue 起票

    必要な調査は適切な read-only lane へ委譲してよい。

    SubAgent の起動前に current .claude/agents/*.md の frontmatter、tools、preloaded skills、permission mode、nested delegation 制約を確認する。

    各 SubAgent には実値で以下を渡す。

    • task / target Issue・PR
    • authority と current HEAD
    • Allowed Paths / constraints
    • 必要な artifact / source evidence
    • expected result schema
    • completion criteria

    親 thread の暗黙 context に依存させない。

    SubAgent を dispatch しただけで完了扱いしない。

    canonical Common Completion Protocol に従う。

    1. dispatch した task name を記録する
    2. wait_agent / completion notification で終了を待つ
    3. final result を取得する
    4. list_agents で当該 task の terminal completed を確認する
    5. result schema・HEAD・evidence を検証する
    6. downstream dependency へ進む

    timeout、intermediate update、errored、interrupted、shutdown、not_found は成功ではない。

    独立した作業は並列実行してよい。依存する作業は必ず join 後に進める。

    7. Review / fix loop

    次のサイクルを実行する。

    inspect → implement → test → PR → current-head adjudication → PR review → fix → re-test → fresh re-review

    Step 4 では current repository の step4-adjudicate を使用する。

    • invoke_pr_reviewer: true / exit 0 の場合だけ reviewer を起動
    • exit 1 の場合は実原因を解消し、必要なら Step 2 を再実行
    • state persist failure では既存 PASS の失効未確認を成功扱いしない
    • --reuse-stored は canonical に適格な場合だけ使用

    REQUEST_CHANGES であれば findings を fix_delta として worker に渡す。修復、commit、push、テスト、CI、fresh review を反復する。

    CI failure は required check の具体的 failed log を取得して root cause を修正する。CI pending / skipped を PASS に変換しない。

    BEHIND なら正式 update_branch route、HEAD が進んだ場合は fresh review route を使う。

    step5-terminal-gate の exit 0 以外で approved を宣言しない。

    最終判定は live HEAD、current binding、stored adjudication、dispatch seq、reviewer verdict、required CI、live mergeability の組合せで行う。

    8. 再発防止 Issue

    実装中に新しい独立 defect を発見した場合、repository 内の OPEN/CLOSED Issue、PR、dedupe_key を検索する。

    既知の関連範囲:

    既存 Issue が所有する問題は二重起票しない。

    未所有の独立 defect を再現できた場合は、issue-creator / create-issue の現行正式経路で実際に GitHub Issue を起票する。

    root cause、再現 evidence、impact、最小修正、AC、VC、Allowed Paths、dedupe_key、関連 Issue を含める。

    起票後は SubAgent terminal result と GitHub readback を確認する。

    9. 停止境界

    通常の修復可能な失敗で停止しない。

    ただし次は canonical policy に従って停止または escalation する。

    • 実 Git conflict の hard stop
    • destructive / irreversible operation
    • credential / secret 操作
    • 他タスクの worktree・dirty state への侵入
    • 解消不能な authority / scope conflict
    • formal human_judgment_required
    • verified evidence integrity failure
    • canonical iteration / no-progress 上限到達
    • permissions / policy bypass が不可避
    • ユーザーの明示停止

    新規 issue の起票権限は既に承認済みだが、#2996 の write scope を自動拡張する権限ではない。

    10. 完了条件と最終報告

    次をすべて確認する。

    1. 実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する #2996 の AC1〜AC5 を実装
    2. Allowed Paths 遵守
    3. 実 failure → fix → PASS の regression evidence
    4. 必須 Verification Commands と required CI の fresh 結果
    5. 最新 PR HEAD での PR review
    6. 未解決の blocking finding がない
    7. step5-terminal-gate が exit 0
    8. 全 SubAgent が terminal completed
    9. GitHub PR の更新・readback が成功
    10. PR は人間がマージ判断できる状態
    11. 実 merge、auto-merge、post-merge cleanup は未実行

    日本語の最終報告には次を含める。

    • Issue / PR URL
    • base・HEAD SHA / worktree
    • 実装変更と AC 対応
    • Verification Commands と実結果
    • regression の before / after evidence
    • required CI 結果
    • review iteration と各 verdict
    • 修復履歴
    • 未解決 warning / blocker
    • 再発防止 Issue の created / reused / skipped
    • canonical terminal status
    • merge_ready の根拠

    承認済みの通常作業について人間の都度承認を求めず、canonical workflow が許す範囲で最後まで実行する。

    まず fresh repository / Issue / PR / Task Context state と current Skill を確認し、正式 entry から開始せよ。

    再発防止 Issue の扱い

    既に [#3005](#3005) が起票されています。また、Task Context の identity 問題には既存の [#2835](#2835) が存在します。

    今回の調査では、これらと独立した新たな defect は確定していないため、重複 Issue は追加起票していません。 実装時に新しい failure class が実証された場合のみ、プロンプト内の指示に従って起票する方針です。

    このプロンプトは、現在確認できる #2996 の契約と impl-review-loop の実行境界に合わせています。

  7. changed the title [-]再発防止: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する[/-] [+]実装: impl-review-loop Step 4 の ensure snapshot envelope と adjudicator 入力の不整合を解消する[/+] on Oct 10, 2026
  8. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    Issue 契約の限定改訂(AC2 / AC4)

    operator が明示指定した PR #3008 の敵対的レビュー(#3008 (comment) 、HEAD 2e21c802、REQUEST_CHANGES)と、operator の本セッション指示に基づく、Claude による bridge 記録です。この comment は人間が直接投稿したものではなく、出所は上記 URL です。

    • AC2: comment 選択規則を、producer と同じ precedence(最新の trusted かつ fingerprint-ready な go を authority とし、最新 trusted blocked は拒否)へ整合させた。fingerprint 未完成の provisional go は既存の fingerprint-ready go を失効させない。「最新 trusted result の comment id と一致」という過剰な条件を撤去した。trusted author・fingerprint・comment id・repo・Issue・body digest の束縛は維持。
    • AC4: 型不正 envelope(status / source の型不正、巨大な --producer-exit-code)の stateful regression と、provisional go の producer → consumer regression を追加した。
    • Allowed Paths と Verification Commands は変更していない。
  9. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  10. squne121 commented on Oct 10, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-10-10T02:25:32Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/2996
      body_sha256: "sha256:5627bdee2949586e659c6d270c3d7468e96f2dcb816305405c7604d9f435d5c1"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:5627bdee2949586e659c6d270c3d7468e96f2dcb816305405c7604d9f435d5c1","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_nh_tllli.md"}}
        vc_preflight:
          decision: pass
          classifications: '[{"ac":"AC3","line":3,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py -q","command_hash":"sha256:dd5e37afb8fdf12a4f006dd6da0c03aef6234d8f4f3e5593abf7ba7ad8609fd8","execution_key_hash":"sha256:12c254d6afd0fc1a4f7ccd549ca9a311b6c396cdbc69da41afca5e2fad7cc025","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 40%]","........................................................................ [ 80%]","...................................                                      [100%]","179 passed in 1.75s"],"stdout_truncated":false,"stdout_original_line_count":5,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2751,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: pass"},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:3f49cb2fd51608b891aa6fccd44486ddd28f180da4c7172a825a4bed33cedf18"}},{"ac":"AC1,AC2,AC3,AC4","line":10,"raw_command":"uv run --locked pytest .claude/skills/impl-review-loop/tests/test_step4_contract_snapshot_handoff.py -q","command_hash":"sha256:c3b778821bb9540b536d7fe00325edec306132d164ed0e113b774b24aed078d5","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:a3c3c724694f89ca789da0f950f9ab9d022cbfb09f416922fe54f30e8aacc4cc"}},{"ac":"AC5","line":14,"raw_command":"rg -n \"producer-exit-code\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:3fd5d33cbbede4e98c5b0aa75b74d98c49a922a610da063f8d5d96d3abf9f0b2","execution_key_hash":"sha256:d1fdadae7829d098064902f4d0a59947e33455a0c3cda9c53fc16ae315fbebd8","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":3,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":13,"raw":"# baseline-expect: fail"},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:7bdb772c1f31c54e595e516e97cbaa8c590e9fdb51ff7fe76800e56eaf07690a"}},{"ac":"AC_UNKNOWN","line":15,"raw_command":"rg -n \"existing_go\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:19416c13c841e421aeee893c7340fdb82a80f209d5deeb4e21ac24b880fae348","execution_key_hash":"sha256:d211f7a4fca2d5d469e67bd17c54db557d7f33e74ba219b17b74ab98c7916566","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":7,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:8bf718e3221b76bfd824e5e7823e3506ddc5a572da65b9ad684572531b56997f"}},{"ac":"AC_UNKNOWN","line":16,"raw_command":"rg -n \"dry_run_would_post\" .claude/skills/impl-review-loop/steps/step-4-pr-review.md","command_hash":"sha256:f03b78975bce7a3ee56cfbf24148c59830f0f58d8f2b11c910365b1637b22355","execution_key_hash":"sha256:7feb1aec07784f6bd588f02fd48f8961ffe49296af3473ad152a7adcde61bb6d","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{"RIPGREP_CONFIG_PATH":"__baseline_vc_preflight_env_unset__"},"duration_ms":8,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:ec6939e30131fac6874bb802d1602bd44ae53ad127b7d965eb31854e30d9f893"}}]'
          classifications_transport: {"schema":"vc_preflight_classifications_transport/v1","classification_count":5,"original_payload_sha256":"sha256:11e0b70917d317b784949719d5ed2f3f9e83139b622d0d44db19c3b6fe5293d4","compact":false,"truncated":false}
        declared_path_overlap: '{"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"dde7773a2e0a5f3ec140bd414817f48c2964c5da","draft_policy":"include_drafts","prs":[{"number":2831,"title":"実装: Claude-GPT model/proxy runtime migration の3分類ルーティングを追加する","base_ref_name":"main","head_ref_name":"worktree-issue-2810-runtime-migration-classifier","head_ref_oid":"7c06e272c14b2d38e8f01899abdf85f3d0d5c9ec","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2831","changed_files_count_graphql":20},{"number":2914,"title":"fix: test-runner が mergeStateStatus=BLOCKED/UNSTABLE だけで TEST_VERDICT を FAIL にしないようにする","base_ref_name":"main","head_ref_name":"worktree-issue-2908-test-runner-blocked-not-fail","head_ref_oid":"2f44329742e2117b1bbbb34452417362558175aa","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2914","changed_files_count_graphql":1},{"number":2931,"title":"fix: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped workspace で解消する","base_ref_name":"main","head_ref_name":"worktree-issue-2860-run-scoped-scratch","head_ref_oid":"344f5da35326e04dacd13aa57dd962674888f336","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2931","changed_files_count_graphql":6},{"number":2940,"title":"feat: runner evidence に main-session init の permission_mode_observed を出力する","base_ref_name":"main","head_ref_name":"worktree-issue-2935-main-session-permission-mode","head_ref_oid":"37eb1ae20b98cc72fed816a7c88aca0d9b623a39","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2940","changed_files_count_graphql":3},{"number":2946,"title":"fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941)","base_ref_name":"main","head_ref_name":"worktree-issue-2941-claude-2-1-289-causal-evidence","head_ref_oid":"0fbc32e03e377b36d5800c940ab8311479c8cf46","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2946","changed_files_count_graphql":1},{"number":2974,"title":"fix: component-vrt-report の negative-control artifact を run_attempt 単位名に束縛する (#2969)","base_ref_name":"main","head_ref_name":"worktree-issue-2969-vrt-negctl-attempt-artifact","head_ref_oid":"2ab61441acc3f5062fa83fd147f570958f2dea3e","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2974","changed_files_count_graphql":2},{"number":3001,"title":"fix: repo-local 証跡を外部 claim の Web gate から分離する","base_ref_name":"main","head_ref_name":"worktree-issue-2857-repo-local-claims","head_ref_oid":"7cb6f7b03f99d89232596d67d6446966d29952d3","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3001","changed_files_count_graphql":5},{"number":3008,"title":"fix: Step 4 が ensure_contract_snapshot の envelope を handoff 経由で受け取れるようにする (#2996)","base_ref_name":"main","head_ref_name":"worktree-issue-2996-step4-snapshot-handoff","head_ref_oid":"3d66269872c3f02bb57c43aca8b8391c39757a70","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3008","changed_files_count_graphql":4},{"number":3009,"title":"fix: contract snapshot 自己投稿直後の updatedAt 時差による false-stale を防ぐ (#3004)","base_ref_name":"main","head_ref_name":"worktree-issue-3004-snapshot-updated-at-race","head_ref_oid":"4a9ae143b976c02dcf33687b2740d785bbfc47f3","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3009","changed_files_count_graphql":2},{"number":3010,"title":"fix: wait_ci_checks が Ruleset の全ページを取得し required context の false-green を防ぐ","base_ref_name":"main","head_ref_name":"worktree-issue-2998-wait-ci-ruleset-pagination","head_ref_oid":"97131bece843f2990c220e7fbe21b6b0d9e65ee7","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3010","changed_files_count_graphql":2},{"number":3011,"title":"fix: HTML-only / bracketed severity 見出しを semantic review 適用判定で検出する (#2994)","base_ref_name":"main","head_ref_name":"worktree-issue-2994-html-bracketed-severity-trigger","head_ref_oid":"5d4dd201a8ebad44b184e877d2070c43f4d39734","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/3011","changed_files_count_graphql":4}],"fetched_count":11,"totalCount":11,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:9f0c67484dc2de3d69bbe26ac41c0204bc8713ae27e36ee44bef4a880a82f3d5","errors":[]},"inventory_digest_extended":"sha256:973a5d0dfbbc82e7c93cbc8352a48e5e682a98b916a9919c3cc48a0f74da222a","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}'
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: '{"issue_number":2996,"contract_source_kind":"issue_comment","contract_source_id":"6092705028","contract_body_sha256":"sha256:5627bdee2949586e659c6d270c3d7468e96f2dcb816305405c7604d9f435d5c1","allowed_paths_normalized_sha256":"e8eb5fd234b7fcb0be3e1d4ee78ad2fb13cea9c3d0b3d55016d00fa7d9634f64","base_ref":"main","base_sha_at_snapshot":"dde7773a2e0a5f3ec140bd414817f48c2964c5da"}'
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions