Skip to content

実装: impl-review-loop intakeにevidence-based landing dispositionを実装する #2699

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2680"
goal_ref: "current implementation scope already landed を evidence-based に判定し、duplicate impl-review-loop dispatch を pre-Step-1 intake で防ぐ"
change_kind: workflow
dedupe_key: "follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/issues/2680#issuecomment-5754018782:implementation-landed-intake-v1"
parent_contract_body_sha256: "sha256:83de3dfdb529d670ed734bc1073a8d2683713b009ce301713612ec6528c51756"

Parent Issue

#2680

Parent Goal Ref

  • Goal: post-merge recovery で current implementation scope が既に landed している場合に duplicate impl-review-loop dispatch を防ぐ。
  • Desired Destination: root_entry_router の freshness / integrity 境界を維持しつつ、impl-review-loop pre-Step-1 intake が evidence-based disposition を実行できる状態。

Current Validated Scope

Remaining Parent Gaps

Outcome

impl-review-loop が worker dispatch、worktree 作成、new PR 作成より前に、identity・candidate provenance・lifecycle・main ancestry・scope coverage・freshness から導出した landing disposition を適用し、current scope が landed 済みの duplicate work を開始しない。IMPLEMENTATION_SCOPE_COVERAGE_V1 は PR 作成時点で production 上に durable に記録され、intake 側はそれを read-only で参照するだけであり、producer 不在のまま retrieval だけを実装しない。

Scope Collision Note

敵対的レビュー由来の設計修正(OWNER anchor comment 反映)

以下は OWNER の敵対的レビュー(issue-refinement-loop による fresh re-investigation で妥当性を再検証済み)を反映した設計修正であり、旧版 Issue 本文にあった未解決の P0/P1/P2 findings を解消する。

Durable Scope Snapshot: Producer / Consumer 責務分離(P0-1 対応)

  • Producer(新規、open-pr skill 所有): .claude/skills/open-pr/scripts/open_pr.py の PR 作成経路(main() / create_pr() の呼び出し前)で、対象 Issue の現在の body を fetch し、下記「Canonical Implementation Scope Normalizer」で定義する manifest を構築し、schema_version 固定の canonical serialization で digest を計算し、以下の IMPLEMENTATION_SCOPE_COVERAGE_V1 block を PR body に埋め込んでから PR を作成する。新しい registry・署名・attestation framework は追加しない。
    IMPLEMENTATION_SCOPE_COVERAGE_V1:
      schema_version: IMPLEMENTATION_SCOPE_COVERAGE_V1
      issue_number: <int>
      issue_body_sha256: <sha256>            # PR 作成時点の live issue body の sha256
      normalized_scope_manifest_sha256: <sha256>  # scope_manifest の canonical bytes の sha256
      pr_head_sha: <sha>                      # PR 作成時点のブランチ HEAD。audit-only metadata(下記「pr_head_sha の用途」参照)。disposition 判定のいずれの分岐にも consume されない
      scope_manifest: <object>                # 下記 normalizer が生成する manifest そのもの(inline 埋め込み。historical body の再取得を不要にする)
    pr_head_sha の用途: 監査証跡(audit trail)専用のフィールドであり、disposition 導出ロジック(Disposition Precedence / Legacy Compatibility Policy / Freshness rebind のいずれも)はこの値を read しない。Freshness rebind(下記)が参照する候補 PR の head sha は、常に決定直前の live fetch 値であり、この埋め込み値ではない。AC1 はこのフィールドの埋め込み自体(audit trail としての存在)のみを要求し、それを消費する disposition ロジックの存在は要求しない。
  • Consumer(既存 Allowed Paths、impl-review-loop 所有): implementation_landed_evidence.py が qualified candidate PR の body/comment から IMPLEMENTATION_SCOPE_COVERAGE_V1 block を parse する。block が存在しない場合(legacy PR、下記「Legacy Compatibility Policy」参照)は current body から merge-time scope を推測せず、covered_exactly を導出不能として扱う。block が存在する場合、normalized_scope_manifest_sha256 を再計算して scope_manifest の改竄有無を検証し、現在の live Issue body に対して同じ normalizer を再適用した manifest と scope_manifest(PR 作成時点の immutable snapshot)を比較する。

Legacy Compatibility Policy(P0-1 派生、markerless open/draft candidate の扱いを含む)

  • merged candidate: IMPLEMENTATION_SCOPE_COVERAGE_V1 block を持たない merged 候補 PR(例: 現行 feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137)は、current body から merge-time scope を推測しない。implementation_already_landed を導出せず、下記「Disposition Precedence」に従い already_satisfied early-exit(現在の main が独立に AC を満たす場合)または ordinary_dispatch_or_explicit_recovery / reconciliation_required にフォールバックする。
  • open/draft candidate(marker 付き): IMPLEMENTATION_SCOPE_COVERAGE_V1 marker が存在する場合、merged candidate と同じ digest 比較(covered_exactly か否か)で current-scope ownership を判定する。covered_exactly なら existing_pr_resume、そうでなければ(marker 記録後に Issue 側でスコープが拡張された等)reconciliation_required とする。
  • open/draft candidate(markerless、rollout 初期を含む): merged candidate とは異なり、marker が無くても existing_pr_resume へ到達できる。open/draft candidate は「immutable な過去の PR 作成時点」ではなく「現在も変更可能な進行中の branch」であるため、marker が存在しない場合に限り、決定時点で以下の Allowed Paths ファイルカバレッジ check を current-scope ownership の代替判定として行う(marker が存在する候補には本 check を適用しない): 候補 PR の変更ファイル一覧(gh pr view <n> --json files の path 集合、各要素を P とする)を取得し、現在の Issue ## Allowed Paths の各エントリ E について、P == E または P が E + "/" から始まる(path-segment 境界を尊重した prefix 一致。単純な文字列 prefix 一致は使わず、.claude/skills/impl-review-loop が .claude/skills/impl-review-loopX/foo.py に誤マッチしないようにする)変更ファイルが 1 件以上存在するかを確認する。すべての Allowed Paths エントリがこの条件を満たせば current-scope ownership ありと判定し existing_pr_resume とする。1 件でも満たさない Allowed Paths エントリがあれば(= PR 作成以降に Issue 側でスコープが拡張され、PR がまだそれに追従していない可能性がある)、existing_pr_resume とはせず reconciliation_required とする(duplicate work を避けるため、盲目的に ordinary_dispatch_or_explicit_recovery へは倒さない)。
  • この compatibility policy(merged/open/draft 双方)は AC9(下記、narrowed runtime verification)で live 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119/feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137 に対して直接検証する。

Disposition Precedence(P0-2 対応、既存 #2607 との合成)

新しい enum を追加せず、既存 route_loop_verdict_v2.py::resolve_already_satisfied_early_exit_decision()(#2607 / PR #2626)をそのまま再利用し、以下の優先順位で choke point を構成する(impl-review-loop/steps/preparation.md の pre-Step-1 choke point を更新)。

  1. evidence invalid / contradictory / stale / identity mismatch → reconciliation_required(marker が存在するが malformed、schema/identity/digest が invalid、または decision-time freshness が証明できない場合を含み、candidate lifecycle が open/draft/merged のいずれであってもこの判定を優先する)
  2. qualified candidate が landing authority を提供できない場合(discovery 自体が候補ゼロの no-qualified-candidate、または全候補が identity/relation qualification 基準で非該当、または closed-unmerged のように qualified ではあるが本質的に landing authority を持ち得ない候補しか存在しない場合のいずれか)AND 既存 resolve_already_satisfied_early_exit_decision() が base_ac_satisfied=true を返す → 既存 already_satisfied early-exit をそのまま適用する(新 disposition が上書きしない。closed-unmerged 候補の存在は already_satisfied フォールバックを妨げない)
  3. merged qualified candidate AND merge_commit_oid の current-main ancestry 検証済み AND IMPLEMENTATION_SCOPE_COVERAGE_V1 durable marker による exact coverage(covered_exactly) → implementation_already_landed
  4. verified open/draft qualified candidate AND current-scope ownership(marker 付きなら covered_exactly、markerless なら上記「Legacy Compatibility Policy」の Allowed Paths カバレッジ check で判定) → existing_pr_resume
    4b. markerless open/draft qualified candidate だが Allowed Paths カバレッジ不足(current-scope ownership なし) → reconciliation_required(ordinary_dispatch_or_explicit_recovery ではない。上記「Legacy Compatibility Policy」参照)
    4c. marker 付き open/draft qualified candidate だが covered_exactly でない場合(marker 記録後に Issue 側でスコープが拡張された等) → reconciliation_required(ordinary_dispatch_or_explicit_recovery ではない。上記「Legacy Compatibility Policy」の open/draft candidate(marker 付き)節、および derive_landing_disposition() の open/draft branch 末尾 fallback(reason_codes: open_draft_scope_ownership_not_exact)と一致させる)
  5. 上記のいずれにも該当しない(closed-unmerged かつ base 未充足、no-candidate かつ base 未充足、later scope expansion、merged qualified candidate で marker 自体は valid だが PR merge 後の Issue スコープ拡張により covered_exactly でない場合(legacy_or_later_scope_expansion)、merged legacy marker 欠落など) → ordinary_dispatch_or_explicit_recovery

no-qualified-candidate → ordinary_dispatch_or_explicit_recovery を無条件の既定にせず、必ず手順 2 の already_satisfied early-exit 判定を先に評価することで、#2607 の duplicate suppression を保持する。

Canonical Implementation Scope Normalizer(P1 対応)

manifest に含めるフィールド(semantic fields、implementation scope を構成するもの):

  • goal_ref / change_kind(Machine-Readable Contract より)
  • implementation-owned ## In Scope の箇条書き項目(テキストのみ、チェックボックス状態は除外)
  • ## Acceptance Criteria の項目テキスト(チェックボックスの [ ]/[x] 状態は除外し、AC 文言のみを対象にする)
  • ## Allowed Paths の項目一覧

manifest から除外するフィールド(operational prose、進捗状態):

  • ## Remaining Parent Gaps の現在値、進捗を示す prose
  • checkbox の checked/unchecked 状態そのもの
  • runtime evidence、closure-only quality gate の status(例: Quality Decision Record.Status)
  • delegated follow-up の進捗記述

各 semantic field のリスト要素(## In Scope / ## Acceptance Criteria / ## Allowed Paths の各箇条書き)は、記載順序を意味論的に非依存として扱う。canonical serialization の前段で各リストを要素テキストの昇順(Python の sorted() の既定 lexicographic order)にソートしてから manifest に格納する。これにより、内容を変えずに箇条書きの記載順序だけを入れ替える編集では digest が変化しない。

canonical serialization: 上記ソート済みリストを含む schema_version 付き dict を json.dumps(manifest, sort_keys=True, separators=(",", ":"), ensure_ascii=False) で UTF-8 encode し sha256 を取る。RFC 8785/JCS のような外部依存は追加しない。producer(open-pr)と consumer(impl-review-loop)は同一の normalizer 実装を参照する(implementation_landed_evidence.py に定義し、open_pr.py から sys.path 経由で import する。既存の finalize_no_diff_issue.py 等が使う cross-skill import pattern を踏襲し、新しい共有パッケージは作らない)。

Multi-Candidate Resolution(P1 対応)

candidate discovery は以下の順序で行う。

  1. bounded discovery: gh pr list --state all --json number,closingIssuesReferences に加えて、対象 Issue の GitHub timeline から cross-referenced イベントを収集する(下記「Cross-Reference Parsing Semantics」参照)。
  2. dedupe: (repo, pr_number) の組で重複除去する。
  3. classify: 各候補を relation(closing / verified_non_closing)、lifecycle(merged / open / draft / closed_unmerged)、identity(source.issue.pull_request の有無で PR であることを確認済みか)で分類する。
  4. qualified candidate resolution: 分類後の候補のうち disposition 導出に使える候補(closing relation を優先し、無ければ verified non-closing)が 1 件なら評価に進む。2 件以上が競合し一意に解決できない場合は reconciliation_required とする。

Cross-Reference Parsing Semantics(P2 対応)

  • GitHub timeline cross-referenced イベントの source.type は PR でも常に "issue" である。PR かどうかは source.issue.pull_request フィールドの存在で判別する。
  • closing relation は gh pr view <n> --json closingIssuesReferences(対象 Issue 番号を含むか)で判定する。Closes / Fixes / Resolves 系キーワードのみが GitHub 公式の auto-close linkage であり、Refs はこれに含めない。
  • generic Refs 文言、title 文字列一致、branch 名の正規表現一致、単なる merged state のみでは landing authority としない(#2565 pr_merged_observed 単独も同様)。

Freshness / Decision-Time Rebind(P1 対応)

  • disposition 確定の直前に、issue body sha256 / 候補 PR の head sha(open/draft の場合)または merge_commit_oid(merged の場合)/ current main HEAD sha を再取得する。
  • collection 開始時に記録した値と不一致な場合、bounded に 1 回だけ discovery + evaluation をやり直す。再試行後も不一致なら reconciliation_required(reason: freshness_rebind_failed)とする。
  • 単純な observed_at TTL のみを authority にしない。

Runtime Verification Applicability

decision: immediate
reason: pre-Step-1 intake は GitHub read transport と live Issue / PR evidence を消費するため、fixture-only test で代替できない read-only runtime verification が本 Issue 内で成立する。AC12 は discovery / identity / relation / main ancestry / legacy compatibility policy(durable marker 欠落時の non-landed 判定)という live で検証可能な transport claim に限定し、covered_exactly を伴う production E2E(producer が生成した durable marker を消費する scope coverage → disposition の判定)は、durable manifest producer を実際に通した fixture / test path(AC10)で証明する。AC12 単独で「scope coverage 判定が live で正しく動く」ことまでは主張しない。
applicable_acs: [AC12]
execution_environment: authenticated `gh` CLI で public `squne121/loop-protocol` の read-only Issue / PR metadata を取得できる worktree。
skip_conditions: 認証、ネットワーク、または GitHub read transport が利用不能な場合、runtime verifier は `SKIP:` を先頭に出力して exit 77 とし、Stop Condition を発火する。
fallback_policy: fixture / cached result / title・branch regex のみで成功した結果、または fallback を含む結果は PASS としない。
artifact_requirements: `artifacts/runtime-verification-AC12-<timestamp>.log` に source URL、body / commit digest、command、output、PASS / FAIL / SKIP を保存する。

In Scope

  • .claude/skills/impl-review-loop/scripts/implementation_landed_evidence.py を追加し、IMPLEMENTATION_LANDED_EVIDENCE_V1 の strict parser / validator、IMPLEMENTATION_SCOPE_COVERAGE_V1 の canonical normalizer(producer/consumer 共有)、disposition derivation を実装する。
  • .claude/skills/open-pr/scripts/open_pr.py に、PR 作成時に IMPLEMENTATION_SCOPE_COVERAGE_V1 durable marker を PR body へ埋め込む producer 呼び出しを追加する(implementation_landed_evidence.py の normalizer を import して使う)。
  • .claude/skills/impl-review-loop/scripts/build_intake_capsule.py に、closing relation または verified cross-reference から得た candidate inputs と live identity / freshness を bounded に収集し、intake evidence を渡す接続を追加する。
  • .claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.py と steps/preparation.md を更新し、pre-Step-1 common choke point が「Disposition Precedence」節の順序で already_satisfied(既存 route 再利用)、implementation_already_landed、existing_pr_resume、ordinary_dispatch_or_explicit_recovery、reconciliation_required を evidence から導出してから data-plane に進むようにする。
  • .claude/skills/impl-review-loop/SKILL.md を更新し、新しい pre-Step-1 disposition と既存 already_satisfied durable contract の記述を整合させる。
  • 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 / PR feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137 non-closing candidate(legacy marker 欠落)、durable marker 付き merged closing candidate、scope expansion、open / draft resume、closed-unmerged、no candidate、stale / contradictory / insufficient evidence、多候補競合を fixture と regression test で実装する。
  • runtime verifier を追加し、read-only live 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 / PR feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137 metadata で provenance / main ancestry / legacy compatibility policy / fallback rejection を記録する。

Out of Scope

  • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py の lifecycle state machine 化または input schema への lifecycle field 追加。
  • generic Refs、title、branch name、cross-reference、merged state、または #2565 pr_merged_observed 単独を landing authority にすること。
  • #2565 の strict closing-relation producer の重複実装。
  • #2119、#2137、#2565、#2661 の Issue / PR mutation。
  • new lifecycle registry、write-capable GitHub API、Issue / PR 自動 close、merge。
  • RFC 8785 / JCS 等の外部 canonicalization 依存の追加。
  • open-pr skill の PR body validator(validate_pr_body.py 等)の日本語比率・hygiene チェック仕様の変更。producer は既存 validator を通る body を生成するだけで、validator 自体は変更しない。

Acceptance Criteria

  • AC1: open_pr.py の PR 作成経路が、PR 作成時点の live Issue body から canonical normalizer で scope_manifest を構築し、IMPLEMENTATION_SCOPE_COVERAGE_V1(issue_number / issue_body_sha256 / normalized_scope_manifest_sha256 / pr_head_sha / scope_manifest)を PR body に埋め込んでから PR を作成する。
  • AC2: canonical normalizer が「Canonical Implementation Scope Normalizer」節の semantic fields のみを manifest に含め、operational prose / checkbox 状態 / runtime evidence / delegated follow-up 進捗を除外し、それらのみが変化しても digest が不変であること、および各リストの記載順序だけを入れ替えても digest が不変であること(順序非依存のソート正規化)を検証する。
  • AC3: IMPLEMENTATION_LANDED_EVIDENCE_V1 producer / parser / validator が target repository / Issue / body、candidate provenance / relation / lifecycle、merge OID / current-main ancestry、state-specific coverage、freshness を検証し、不足・型不正・identity mismatch・stale を landed に補完推論しない。
  • AC4: disposition が「Disposition Precedence」節の順序(reconciliation → 既存 already_satisfied 再利用 → implementation_already_landed → existing_pr_resume → 4b reconciliation → ordinary_dispatch_or_explicit_recovery)で導出され、no-qualified-candidate かつ既存 base_ac_satisfied=true のケース、および closed-unmerged candidate のみが存在し base_ac_satisfied=true であるケースの両方で 実装: impl-review-loop に already_satisfied terminal route を追加する #2607 の early-exit が維持されることを確認する。
  • AC5: IMPLEMENTATION_SCOPE_COVERAGE_V1 durable marker を持たない legacy merged 候補 PR(マーカー欠落)が implementation_already_landed を導出せず、現在の body から merge-time scope を推測しないことを確認する。
  • AC6: markerless open/draft candidate に対して、候補 PR の変更ファイル一覧が現在の ## Allowed Paths 全エントリをカバーする場合に existing_pr_resume になり、1 件でもカバーしない Allowed Paths エントリがある場合に reconciliation_required(ordinary_dispatch_or_explicit_recovery ではない)になることを確認する。
  • AC7: candidate discovery が bounded discovery → (repo, pr_number) dedupe → relation/lifecycle/identity classification → qualified candidate resolution を実装し、2 件以上の qualified candidate が競合する場合に reconciliation_required になることを確認する。
  • AC8: candidate discovery が exact closing relation(closingIssuesReferences)または source.issue.pull_request で判別した verified cross-reference の provenance を記録し、generic Refs、title / branch regex、merged state、#2565 pr_merged_observed のいずれも単独では landing authority にしないことを確認する。
  • AC9: disposition 確定直前に issue body sha256 / candidate head-or-merge-oid / current main sha を再取得し、collection 開始時の値と不一致な場合に bounded 1 回の再評価を行い、再試行後も不一致なら reconciliation_required(reason: freshness_rebind_failed)になることを確認する。
  • AC10: 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 / PR feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137 の legacy(marker 欠落)候補が implementation_already_landed にならないこと、同値の durable marker 付き merged closing fixture は implementation_already_landed になること、scope expansion / open / draft(marker 付き・markerless 双方)/ closed-unmerged / no candidate / contradictory / insufficient evidence の各 fixture が対応する disposition を固定することを回帰保護する。
  • AC11: integration regression が disposition を worker dispatch、worktree creation、new PR creation より先に適用し、implementation_already_landed と reconciliation_required と既存 already_satisfied では三つの data-plane operation を開始せず、existing_pr_resume では duplicate PR を開始しないことを確認する。root_entry_router の lifecycle-free boundary も回帰保護する。
  • AC12: read-only runtime verifier が live 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 / PR feat: Playwright E2E responsive matrix を専用 lane へ分離する #2137 に対して source identity、non-closing relation、merge commit の current-main ancestry、および legacy compatibility policy(durable marker 欠落時に implementation_already_landed を導出しないこと)を取得し、fixture / fallback を PASS に縮退せず runtime verification artifact を出力する。
  • AC13: targeted regression、pnpm typecheck、pnpm lint、pnpm test、pnpm build、model-routing test が PASS し、Allowed Paths 外を変更しない。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/open-pr/tests/test_implementation_scope_snapshot_producer.py::test_open_pr_embeds_implementation_scope_coverage_marker -q

# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_scope_normalizer_excludes_operational_prose_and_progress_state -q

# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_validator_rejects_missing_stale_and_identity_mismatched_evidence -q

# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_disposition_precedence_reuses_already_satisfied_before_landed_evidence -q

# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_legacy_merged_candidate_without_durable_marker_never_yields_implementation_already_landed -q

# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_markerless_open_draft_candidate_allowed_paths_coverage_determines_resume_or_reconciliation -q

# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_candidate_discovery_dedupes_and_reconciles_conflicting_qualified_candidates -q

# AC8
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_candidate_discovery_is_not_landing_authority -q

# AC9
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_decision_time_freshness_rebind_and_bounded_retry -q

# AC10
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py::test_2119_2137_legacy_and_durable_marker_fixture_regressions -q

# AC11
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_intake_integration.py::test_disposition_precedes_worker_worktree_and_new_pr -q

# AC12
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_implementation_landed_intake_integration.py::test_live_runtime_verifier_records_2119_2137_legacy_compatibility_without_fixture_fallback -q

# AC13
# baseline-expect: pass
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q

Allowed Paths

  • .claude/skills/impl-review-loop/scripts/implementation_landed_evidence.py
  • .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
  • .claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.py
  • .claude/skills/impl-review-loop/scripts/verify_implementation_landed_intake_runtime.py
  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py
  • .claude/skills/impl-review-loop/tests/test_implementation_landed_intake_integration.py
  • .claude/skills/impl-review-loop/tests/test_already_satisfied_routing.py
  • .claude/skills/impl-review-loop/tests/test_already_satisfied_early_exit_e2e_runtime_only.py
  • .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py
  • .claude/skills/impl-review-loop/tests/test_preparation_entry_policy.py
  • .claude/skills/open-pr/scripts/open_pr.py
  • .claude/skills/open-pr/tests/test_implementation_scope_snapshot_producer.py
  • .claude/skills/open-pr/scripts/tests/test_open_pr_validation_hook.py
  • .claude/skills/open-pr/scripts/tests/test_open_pr_canonical_repo_regression.py
  • .claude/skills/open-pr/scripts/tests/test_open_pr_overlap_removal.py

上記3件(test_open_pr_validation_hook.py / test_open_pr_canonical_repo_regression.py / test_open_pr_overlap_removal.py)は、open_pr.py の IMPLEMENTATION_SCOPE_COVERAGE_V1 marker 埋め込み変更(AC1)が要求する、既存テストへの mock-only 追加(get_linked_issue_body / resolve_head_sha)のための Scope Delta 拡張である。AC・VC の追加は行わない。

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 動作検証 AC の VC が SKIP(exit 77)を返した場合(実行環境不可のためエスカレーション)
  • fallback 経由でのみ「成功」する場合(FAIL として扱い、実行環境を確認)
  • open_pr.py の producer 追加が既存 PR body validator(日本語比率・Safety Claim Matrix 等)を破壊すると判明した場合

Required Skills

  • なし

Required Design References

  • docs/dev/workflow.md
  • docs/dev/runtime-verification-policy.md
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/issue-refinement-loop/scripts/root_entry_router.py
  • .claude/skills/open-pr/SKILL.md
  • .claude/skills/open-pr/scripts/open_pr.py
  • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
  • https://github.com/squne121/loop-protocol/issues/2680
  • https://github.com/squne121/loop-protocol/issues/2699#issuecomment-5755952589
  • https://github.com/squne121/loop-protocol/issues/2607
  • https://github.com/squne121/loop-protocol/pull/2626
  • https://github.com/squne121/loop-protocol/issues/2119
  • https://github.com/squne121/loop-protocol/pull/2137

Source

Delivery Rule

1 Issue = 1 PR。canonical worktree を使用し、Draft PR を既定とする。merge は行わない。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Sep 21, 2026
  2. squne121 commented on Sep 21, 2026

    @squne121
    OwnerAuthor

    結論

    #2699 の問題設定と実装場所は妥当です。特に、root_entry_router を lifecycle state machine にせず、impl-review-loop の pre-Step-1 choke point で duplicate work を止める方針は、#2680 の調査結果と既存 #2607 の設計に整合しています。

    一方、現在の Issue contract のまま実装に入るのは要修正です。中心となる IMPLEMENTATION_SCOPE_COVERAGE_V1 の「merged 時点 snapshot」が production で生成できないことと、既存 #2607 の already_satisfied route を AC4 が壊し得ることが大きいです。#2699 には現時点でコメントはなく、参照する実装 PR も確認できていないため、コード着手前に直す余地があります。

    敵対的レビュー findings

    Severity | Finding | 影響 -- | -- | -- P0 | immutable merged snapshot の producer / 永続化地点が存在しない | AC2/AC3/AC6 が fixture だけ green になり、production では covered_exactly を導出不能 P0 | AC4 の no-qualified-candidate → ordinary_dispatch が #2607 の既存 early-exit と衝突 | 既に main が要求を満たす no-PR Issue で duplicate implementation を復活させる P1 | 「current implementation scope」の canonical normalizer が未定義 | prose/status 更新を scope expansion と誤認、または本物の追加実装を見逃す P1 | candidate が単数だが discovery は本質的に複数候補を返し得る | merged/open/closed PR 混在時に first-hit 依存・誤抑止 P1 | AC9 が core claim の scope coverage / disposition を live 検証しない | 最難関ロジックが壊れたまま runtime verification PASS が可能 P1 | freshness が observed_at 中心で decision-time 再束縛が弱い | Issue/PR/main が途中で変化した TOCTOU evidence を消費し得る P1 | impl-review-loop/SKILL.md が Allowed Paths 外 | production routing と durable skill contract が乖離する P2 | cross-reference の concrete parsing rule が不足 | GitHub timeline の source.type を誤解しやすい P2 | content-addressed manifest の canonical serialization が未固定 | 同じ意味の JSON が別 digest になり得る

    P0-1 — 「merged snapshot」は intake 時点では作れない

    #2699 AC2 は、

    immutable merged snapshot と live current scope を content-addressed manifest に正規化

    することを要求しています。しかし現在の Allowed Paths は impl-review-loop の intake/read 側だけです。PR が merge された後に初めて intake が走っても、当時の Issue implementation scope は既に失われている可能性があります。

    既存の scripts/agent-guards/materialize_issue_scope_snapshot.py も代替にはなりません。このファイル自身が ISSUE_SCOPE_SNAPSHOT_V1 の disk artifact を audit trail only と定義し、authorization source は同一 transaction 内の in-memory snapshot だけ、と明記しています。つまり historical landing evidence の durable authority ではありません。

    これは #2119/#2137 で現実に問題になります。#2137 merge 後、#2119 本文は何度も refinement されています。現在の本文だけから「#2137 merge 時点の implementation scope」を逆算することはできません。

    最小修正は、新しい registry や attestation framework を作ることではありません。既存の PR publication 経路で、implementation 開始時または PR 作成時に小さな IMPLEMENTATION_SCOPE_COVERAGE_V1 block を PR body/comment に残し、

    issue_number
    issue_body_sha256
    normalized_scope_manifest_sha256
    pr_head_sha
    scope_manifest

    程度を固定するのが費用対効果が高いです。merge 後はその marker と merge_commit_oid を read-only で照合するだけにできます。

    そのためには #2699 の Allowed Paths を、少なくともその producer を実際に接続する Step 1 / open-PR 側まで広げる必要があります。producer のない「storage retrieval」だけを実装しないことが重要です。

    historical #2137 のように marker が存在しない legacy case は、別途明示的な compatibility policy が必要です。「現在の body から merge-time snapshot を推定する」は避けるべきです。

    P0-2 — #2607 の duplicate suppression を逆に壊す

    現在 production の route_loop_verdict_v2.py::resolve_already_satisfied_early_exit_decision() は、

    pr_exists == false
    AND
    base_ac_satisfied == true
    → early_exit / dispatch_step1=false

    を実装済みです。これは #2607 / PR #2626 で入った重要な no-op suppression です。

    ところが #2699 AC4 は、

    no-qualified-candidate
    → ordinary_dispatch_or_explicit_recovery

    と固定しています。

    この AC を字面どおり新しい canonical disposition にすると、

    linked/candidate PR はない
    current main は Issue の全 AC を既に満たしている

    という、まさに #2607 が止めているケースを再び Step 1 に流します。

    新旧ロジックの合成順序を AC に固定すべきです。例えば:

    evidence invalid / contradictory
        -> reconciliation_required
    

    no qualified candidate AND existing #2607 base_ac_satisfied
    -> existing already_satisfied early-exit

    merged candidate AND landed-on-main AND exact implementation coverage
    -> implementation_already_landed

    open/draft candidate AND ownership verified
    -> existing_pr_resume

    otherwise
    -> ordinary_dispatch_or_explicit_recovery

    新しい enum を増やす必要すらなく、no-candidate + main-satisfied は既存 already_satisfied をそのまま維持するのが小さい変更です。

    P1 — current implementation scope の意味がまだ曖昧

    全文 Issue body hash は coverage manifest に使えません。#2119 がよい実例です。

    現在の #2119 本文にはまだ「#2679 / Draft PR #2681 が merge 待ち」と残っていますが、fresh GitHub state では PR #2681 は 2026-09-20 に merge 済み、#2679 は CLOSED/COMPLETED です。一方 #2155 は現在も OPEN で、Quality Decision Record.Status: measurement-ready の verification-only gate です。

    つまり operational prose や Remaining Parent Gaps の現在値まで manifest に入れると、implementation code が全く変わっていないのに digest が変わります。

    逆に単に In Scope だけ取ると、AC/Allowed Paths に追加された本物の implementation requirement を見逃す可能性があります。

    最低限、normalizer が対象にする semantic fields と除外する fields を contract に固定すべきです。たとえば goal_ref/change_kind、implementation-owned In Scope、implementation AC、Allowed Paths は対象、checkbox 状態、runtime evidence、closure-only quality gate、delegated follow-up の進捗 prose は対象外、といった境界です。

    特に #2119/#2137 fixture は「現在の全文 Issue と #2137 が exact」と書くのではなく、

    #2137 が所有していた implementation scope は exact covered、#2155 は verification-only delegated remainder

    であることを fixture の oracle にした方が実態に合います。

    P1 — candidate を1件に潰す前のルールがない

    IMPLEMENTATION_LANDED_EVIDENCE_V1.candidate は単数ですが、GitHub timeline には複数の cross-reference が普通に存在し得ます。closing PR と Refs PR、closed-unmerged PR、後続 PR が混在するケースもあります。

    GitHub の timeline cross-referenced event は candidate discovery に適しています。ただし API 上 source.type は PR でも常に "issue" で、PR かどうかは source.issue.pull_request の存在で判別する仕様です。(GitHub Docs)

    実装は、

    discover all bounded candidates
    → repo/pr_number で dedupe
    → lifecycle / relation / identity を分類
    → qualified candidate が 1件なら評価
    → 2件以上が競合するなら reconciliation_required

    程度で十分です。複雑な scorer は不要です。

    なお Refs #2119 を closing relation と同一視しない現在方針は正しいです。GitHub が issue auto-close linkage として定義しているのは Closes / Fixes / Resolves 系です。(GitHub Docs)

    P1 — AC9 は一番重要なものを runtime で証明していない

    AC9 が live #2119/#2137 で確認するのは、

    • source identity

    • non-closing relation

    • merge commit が current main に到達していること

    • fixture fallback を使っていないこと

    までです。

    しかし #2699 の本質は、

    scope coverage == covered_exactly
    → implementation_already_landed
    → Step 1 suppression

    です。AC9 はここを確認しないので、coverage normalizer が production では常に insufficient を返していても runtime test が PASS できます。

    これは P0-1 と表裏です。durable historical snapshot がまだ存在しない以上、現在の #2119/#2137 だけで「live exact coverage」まで証明するのは困難です。

    したがって AC9 は過大主張せず、

    live discovery / identity / ancestry transport の runtime verification

    に限定し、coverage disposition の production E2E は durable manifest producer を導入した新しい実 PR fixtureで証明する方が正確です。

    実装上の細部

    merge commit の main 到達確認には git merge-base --is-ancestor MERGE_OID CURRENT_MAIN が適切です。Git は「ancestor なら 0、そうでなければ 1、その他の non-zero は error」と明確に区別しているため、1 = not_landed と transport/object failure を混同しないようにします。(Git)

    freshness は observed_at の TTL を security gate にするより、判定直前に issue body SHA / PR head or merge OID / current main SHA をもう一度取得し、collection 開始時と一致しなければ bounded retry する方が実用的です。趣味開発ではこの2-read程度で十分で、ledger は不要です。

    また content-addressed manifest を導入するなら、hash 対象 bytes を固定してください。RFC 8785/JCS はこの問題への標準的な解ですが、このリポジトリだけで Python producer/consumer が閉じるなら、依存を増やさず schema_version + deterministic key ordering + fixed separators + UTF-8 を明文化する程度でも十分です。重要なのは producer/consumer が同じ canonical bytes を得ることです。(RFC Editor)

    最後に、新しい disposition は impl-review-loop の公開動作を変えるため、現在 Allowed Paths 外の .claude/skills/impl-review-loop/SKILL.md も更新対象に含めるべきです。現状の SKILL は #2607 の already_satisfied を durable contract として記述しており、コードだけ新しい lifecycle semantics にすると SSOT が即座に stale になります。

    推奨する #2699 の修正方針

    大規模な lifecycle registry、署名、attestation、新しい権限ハーネスは不要です。**「scope snapshot をいつ durable に残すか」「#2607 とどう合成するか」「scope manifest が何を意味するか」**の3点だけ先に固定すれば、かなり小さい実装にできます。

    その3点を反映してから issue-refinement-loop → impl-review-loop に渡すのが適切です。特に P0-1 の producer 不在を解決せず implementation_landed_evidence.py から作り始めると、fixture は高品質なのに production では historical coverage を一度も証明できない実装になる可能性が高いです。

    ## 結論

    #2699 の問題設定と実装場所は妥当です。特に、root_entry_router を lifecycle state machine にせず、impl-review-loop の pre-Step-1 choke point で duplicate work を止める方針は、#2680 の調査結果と既存 #2607 の設計に整合しています。

    一方、現在の Issue contract のまま実装に入るのは要修正です。中心となる IMPLEMENTATION_SCOPE_COVERAGE_V1 の「merged 時点 snapshot」が production で生成できないことと、既存 #2607 の already_satisfied route を AC4 が壊し得ることが大きいです。#2699 には現時点でコメントはなく、参照する実装 PR も確認できていないため、コード着手前に直す余地があります。

    敵対的レビュー findings

    Severity Finding 影響
    P0 immutable merged snapshot の producer / 永続化地点が存在しない AC2/AC3/AC6 が fixture だけ green になり、production では covered_exactly を導出不能
    P0 AC4 の no-qualified-candidate → ordinary_dispatch が #2607 の既存 early-exit と衝突 既に main が要求を満たす no-PR Issue で duplicate implementation を復活させる
    P1 「current implementation scope」の canonical normalizer が未定義 prose/status 更新を scope expansion と誤認、または本物の追加実装を見逃す
    P1 candidate が単数だが discovery は本質的に複数候補を返し得る merged/open/closed PR 混在時に first-hit 依存・誤抑止
    P1 AC9 が core claim の scope coverage / disposition を live 検証しない 最難関ロジックが壊れたまま runtime verification PASS が可能
    P1 freshness が observed_at 中心で decision-time 再束縛が弱い Issue/PR/main が途中で変化した TOCTOU evidence を消費し得る
    P1 impl-review-loop/SKILL.md が Allowed Paths 外 production routing と durable skill contract が乖離する
    P2 cross-reference の concrete parsing rule が不足 GitHub timeline の source.type を誤解しやすい
    P2 content-addressed manifest の canonical serialization が未固定 同じ意味の JSON が別 digest になり得る

    P0-1 — 「merged snapshot」は intake 時点では作れない

    #2699 AC2 は、

    immutable merged snapshot と live current scope を content-addressed manifest に正規化

    することを要求しています。しかし現在の Allowed Paths は impl-review-loop の intake/read 側だけです。PR が merge された後に初めて intake が走っても、当時の Issue implementation scope は既に失われている可能性があります。

    既存の scripts/agent-guards/materialize_issue_scope_snapshot.py も代替にはなりません。このファイル自身が ISSUE_SCOPE_SNAPSHOT_V1 の disk artifact を audit trail only と定義し、authorization source は同一 transaction 内の in-memory snapshot だけ、と明記しています。つまり historical landing evidence の durable authority ではありません。

    これは #2119/#2137 で現実に問題になります。#2137 merge 後、#2119 本文は何度も refinement されています。現在の本文だけから「#2137 merge 時点の implementation scope」を逆算することはできません。

    最小修正は、新しい registry や attestation framework を作ることではありません。既存の PR publication 経路で、implementation 開始時または PR 作成時に小さな IMPLEMENTATION_SCOPE_COVERAGE_V1 block を PR body/comment に残し、

    issue_number
    issue_body_sha256
    normalized_scope_manifest_sha256
    pr_head_sha
    scope_manifest
    

    程度を固定するのが費用対効果が高いです。merge 後はその marker と merge_commit_oid を read-only で照合するだけにできます。

    そのためには #2699 の Allowed Paths を、少なくともその producer を実際に接続する Step 1 / open-PR 側まで広げる必要があります。producer のない「storage retrieval」だけを実装しないことが重要です。

    historical #2137 のように marker が存在しない legacy case は、別途明示的な compatibility policy が必要です。「現在の body から merge-time snapshot を推定する」は避けるべきです。

    P0-2 — #2607 の duplicate suppression を逆に壊す

    現在 production の route_loop_verdict_v2.py::resolve_already_satisfied_early_exit_decision() は、

    pr_exists == false
    AND
    base_ac_satisfied == true
    → early_exit / dispatch_step1=false
    

    を実装済みです。これは #2607 / PR #2626 で入った重要な no-op suppression です。

    ところが #2699 AC4 は、

    no-qualified-candidate
    → ordinary_dispatch_or_explicit_recovery
    

    と固定しています。

    この AC を字面どおり新しい canonical disposition にすると、

    linked/candidate PR はない
    current main は Issue の全 AC を既に満たしている
    

    という、まさに #2607 が止めているケースを再び Step 1 に流します。

    新旧ロジックの合成順序を AC に固定すべきです。例えば:

    evidence invalid / contradictory
        -> reconciliation_required
    
    no qualified candidate AND existing #2607 base_ac_satisfied
        -> existing already_satisfied early-exit
    
    merged candidate AND landed-on-main AND exact implementation coverage
        -> implementation_already_landed
    
    open/draft candidate AND ownership verified
        -> existing_pr_resume
    
    otherwise
        -> ordinary_dispatch_or_explicit_recovery
    

    新しい enum を増やす必要すらなく、no-candidate + main-satisfied は既存 already_satisfied をそのまま維持するのが小さい変更です。

    P1 — current implementation scope の意味がまだ曖昧

    全文 Issue body hash は coverage manifest に使えません。#2119 がよい実例です。

    現在の #2119 本文にはまだ「#2679 / Draft PR #2681 が merge 待ち」と残っていますが、fresh GitHub state では PR #2681 は 2026-09-20 に merge 済み、#2679 は CLOSED/COMPLETED です。一方 #2155 は現在も OPEN で、Quality Decision Record.Status: measurement-ready の verification-only gate です。

    つまり operational prose や Remaining Parent Gaps の現在値まで manifest に入れると、implementation code が全く変わっていないのに digest が変わります。

    逆に単に In Scope だけ取ると、AC/Allowed Paths に追加された本物の implementation requirement を見逃す可能性があります。

    最低限、normalizer が対象にする semantic fields と除外する fields を contract に固定すべきです。たとえば goal_ref/change_kind、implementation-owned In Scope、implementation AC、Allowed Paths は対象、checkbox 状態、runtime evidence、closure-only quality gate、delegated follow-up の進捗 prose は対象外、といった境界です。

    特に #2119/#2137 fixture は「現在の全文 Issue と #2137 が exact」と書くのではなく、

    #2137 が所有していた implementation scope は exact covered、#2155 は verification-only delegated remainder

    であることを fixture の oracle にした方が実態に合います。

    P1 — candidate を1件に潰す前のルールがない

    IMPLEMENTATION_LANDED_EVIDENCE_V1.candidate は単数ですが、GitHub timeline には複数の cross-reference が普通に存在し得ます。closing PR と Refs PR、closed-unmerged PR、後続 PR が混在するケースもあります。

    GitHub の timeline cross-referenced event は candidate discovery に適しています。ただし API 上 source.type は PR でも常に "issue" で、PR かどうかは source.issue.pull_request の存在で判別する仕様です。([GitHub Docs]1)

    実装は、

    discover all bounded candidates
    → repo/pr_number で dedupe
    → lifecycle / relation / identity を分類
    → qualified candidate が 1件なら評価
    → 2件以上が競合するなら reconciliation_required
    

    程度で十分です。複雑な scorer は不要です。

    なお Refs #2119 を closing relation と同一視しない現在方針は正しいです。GitHub が issue auto-close linkage として定義しているのは Closes / Fixes / Resolves 系です。([GitHub Docs]2)

    P1 — AC9 は一番重要なものを runtime で証明していない

    AC9 が live #2119/#2137 で確認するのは、

    • source identity
    • non-closing relation
    • merge commit が current main に到達していること
    • fixture fallback を使っていないこと

    までです。

    しかし #2699 の本質は、

    scope coverage == covered_exactly
    → implementation_already_landed
    → Step 1 suppression
    

    です。AC9 はここを確認しないので、coverage normalizer が production では常に insufficient を返していても runtime test が PASS できます。

    これは P0-1 と表裏です。durable historical snapshot がまだ存在しない以上、現在の #2119/#2137 だけで「live exact coverage」まで証明するのは困難です。

    したがって AC9 は過大主張せず、

    live discovery / identity / ancestry transport の runtime verification

    に限定し、coverage disposition の production E2E は durable manifest producer を導入した新しい実 PR fixtureで証明する方が正確です。

    実装上の細部

    merge commit の main 到達確認には git merge-base --is-ancestor MERGE_OID CURRENT_MAIN が適切です。Git は「ancestor なら 0、そうでなければ 1、その他の non-zero は error」と明確に区別しているため、1 = not_landed と transport/object failure を混同しないようにします。([Git]3)

    freshness は observed_at の TTL を security gate にするより、判定直前に issue body SHA / PR head or merge OID / current main SHA をもう一度取得し、collection 開始時と一致しなければ bounded retry する方が実用的です。趣味開発ではこの2-read程度で十分で、ledger は不要です。

    また content-addressed manifest を導入するなら、hash 対象 bytes を固定してください。RFC 8785/JCS はこの問題への標準的な解ですが、このリポジトリだけで Python producer/consumer が閉じるなら、依存を増やさず schema_version + deterministic key ordering + fixed separators + UTF-8 を明文化する程度でも十分です。重要なのは producer/consumer が同じ canonical bytes を得ることです。([RFC Editor]4)

    最後に、新しい disposition は impl-review-loop の公開動作を変えるため、現在 Allowed Paths 外の .claude/skills/impl-review-loop/SKILL.md も更新対象に含めるべきです。現状の SKILL は #2607 の already_satisfied を durable contract として記述しており、コードだけ新しい lifecycle semantics にすると SSOT が即座に stale になります。

    推奨する #2699 の修正方針

    大規模な lifecycle registry、署名、attestation、新しい権限ハーネスは不要です。**「scope snapshot をいつ durable に残すか」「#2607 とどう合成するか」「scope manifest が何を意味するか」**の3点だけ先に固定すれば、かなり小さい実装にできます。

    その3点を反映してから issue-refinement-loop → impl-review-loop に渡すのが適切です。特に P0-1 の producer 不在を解決せず implementation_landed_evidence.py から作り始めると、fixture は高品質なのに production では historical coverage を一度も証明できない実装になる可能性が高いです。

  3. squne121 commented on Sep 21, 2026

    @squne121
    OwnerAuthor

    確認した範囲では、#2699 は実装開始ではなく Issue contract の再精緻化を先に行うべき状態です。特に P0 の2点――durable scope snapshot producer 不在と #2607 already_satisfied との precedence 衝突――を解消してから implementation handoff に戻すのが妥当です。

    また現行 issue-refinement-loop では canonical Step 2 は issue-reviewer SubAgent を起動しません。一方、semantic review の issue-design-reviewer には明示的な completion join barrier があり、完了待ちが必要です。本文 mutation は issue-editor に委譲する構成が現行契約に合っています。これを踏まえた貼り付け用プロンプトです。

    既に auto mode で起動しているこの Claude Code セッションで、以下を人間の中間承認なしで最後まで実行してください。

    対象:

    • Repository: squne121/loop-protocol
    • Issue: #2699
    • adversarial review anchor:
      https://github.com/squne121/loop-protocol/issues/2699#issuecomment-5755952589
    • 使用する canonical skill:
      .claude/skills/issue-refinement-loop/SKILL.md

    目的は、anchor comment の findings を単純転記することではなく、fresh repository state と関連 Issue / PR / repository assets を再調査した上で issue-refinement-loop の canonical procedure に従い #2699 を implementation-ready な contract まで精緻化することです。

    実行ポリシー

    • このセッションは既に auto mode である。permission mode の変更や再起動はしない。
    • loop iteration、review、rewrite、Issue body update のたびに人間へ承認を求めない。
    • skill が許可している bounded retry / rewrite / semantic rewrite は自律的に消化する。
    • ただし skill の canonical hard-stop / human_judgment_required / operator_intervention_required を勝手に成功扱いへ変換しない。
    • canonical route が継続可能な限り、「人間に確認した方が安全」という理由だけで停止しない。
    • 本タスクは Issue refinement のみ。impl-review-loop、implementation worker、実装 worktree、実装 PR 作成へは進まない。
    • 実装: impl-review-loop intakeにevidence-based landing dispositionを実装する #2699 の refinement が canonical approve / implementation-ready 相当になった時点で終了する。

    最初に読むもの

    最低限、以下を fresh read してから routing を開始すること。

    anchor comment の記述を authoritative truth とみなさず、現在の main / Issue / PR state とコードを SSOT として再検証すること。

    SubAgent orchestration

    SubAgent を使用すること。また、各 SubAgent の完了を待ってから、その結果を必要とする次工程へ進むこと。

    1. read-only investigation

    必要に応じて codebase-investigator 等の read-only sibling SubAgent を main/root session から起動し、少なくとも以下を独立調査させる。

    SubAgent を投げっぱなしにしない。
    必ず completion を待ち、結果を main thread で検証・統合してから root review へ進むこと。

    2. canonical Step 2

    現行 skill 契約に従うこと。

    canonical Step 2 では issue-reviewer SubAgent を新たに起動しない。
    run_root_review_pipeline.py の canonical root-owned pipeline と、その stdout のトップレベル canonical_step2_route を routing authority とする。

    status、prose、旧 compact_result.next_action 等から独自に route を再計算しない。

    3. semantic review

    deterministic review が approve し、semantic_review_trigger.py が applicable と判定した場合は、canonical Step 2.5 を実行する。

    issue-design-reviewer SubAgent を sibling として起動し、completion join barrier を厳守して完了を待つこと。

    完了前に record-result、join_review_results.py、Step 4 rewrite へ進まない。

    join_review_results.py が返す:

    • approve
    • needs-fix
    • retry
    • human_judgment_required

    を canonical contract のまま扱う。

    retry は Step 2.5 内の bounded retry として処理する。
    semantic finding 由来の needs-fix では SEMANTIC_REWRITE_CONSTRAINTS_V1 を再構築・改変せず、そのまま rewrite lane に渡す。

    4. rewrite

    本文 mutation が必要な場合は issue-editor SubAgent / canonical edit-issue route に委譲する。

    issue-editor の完了を待ち、GitHub の fresh readback で更新後本文を確認してから次 iteration を開始する。

    SubAgent から別 SubAgent を nested delegation させない。
    必要な chain は main/root session が sibling SubAgent を sequential に orchestration すること。

    anchor comment から必ず再評価する論点

    以下は「そのまま採用」ではなく fresh review で妥当性を検証し、妥当なら Issue contract に検索可能・テスト可能な形で反映する。

    P0: durable historical scope producer

    現在の IMPLEMENTATION_SCOPE_COVERAGE_V1 が intake/read side の consumer だけを定義し、merge-time implementation scope を production で生成・永続化する producer がない問題を解消する。

    producer のない retrieval/parser だけを実装対象にしない。

    最小変更を優先する。新しい lifecycle registry、署名、attestation framework 等は導入しない。

    fresh investigation で canonical な PR publication / implementation開始経路を確定し、必要なら #2699 の In Scope / Allowed Paths / AC / VC を拡張する。

    候補として open-pr / implement-issue 経路を調査するが、ファイル名を事前に決め打ちしない。

    legacy PR に durable marker が存在しない場合は、現在本文から merge-time scope を推測しない compatibility policy を明文化する。

    P0: #2607 already_satisfied との合成

    no-qualified-candidate -> ordinary_dispatch_or_explicit_recovery を無条件に適用して、既存 #2607 の duplicate suppression を壊さないこと。

    少なくとも以下の precedence を fresh implementation contract と整合させる。

    1. invalid / contradictory evidence
      → reconciliation
    2. candidate が landed authority を提供できず、既存 実装: impl-review-loop に already_satisfied terminal route を追加する #2607 の current-main AC satisfaction が成立するケース
      → existing already_satisfied early-exit を維持
    3. merged candidate + verified main ancestry + durable exact coverage
      → implementation already landed
    4. verified open/draft candidate + current-scope ownership
      → existing PR resume
    5. その他
      → ordinary dispatch / explicit recovery

    既存 route 名を不必要に増やさず、既存 behavior と合成できるならそれを優先する。

    current implementation scope normalizer

    全文 body hash を semantic coverage と同一視しない。

    どの field が implementation scope に含まれ、どの operational prose / progress state / checkbox / delegated remainder が除外されるかを contract に固定する。

    Goal、implementation-owned In Scope、implementation AC、Allowed Paths 等をどう扱うか fresh review で確定し、同値な scope が deterministic canonical bytes / digest を得るようにする。

    canonical serialization も明示すること。
    不要な新規依存は避け、Python 内で閉じられるなら deterministic key ordering / separators / UTF-8 / schema_version 等の簡潔な規則を優先する。

    multiple candidates

    candidate discovery を first-hit 単数前提にしない。

    bounded discovery
    → repo/pr_number dedupe
    → relation/lifecycle/identity classification
    → qualified candidate resolution

    を contract 化する。

    複数の qualified candidate が競合して一意に disposition を導けない場合は reconciliation へ送る。

    cross-reference semantics

    GitHub timeline の cross-referenced event の具体的形状を調査し、PR 判別、closing relation、non-closing verified cross-reference を混同しない parser rule を AC/VC に反映する。

    generic Refs, title, branch-name regex, merged state 単独を landing authority にしない。

    freshness / TOCTOU

    単純な observed_at TTL だけを authority にしない。

    decision 直前に最低限:

    • Issue body identity/hash
    • candidate PR head または merge OID
    • current main SHA

    を再束縛し、collection 開始時と不一致なら bounded retry / reconciliation とする設計を検討する。

    runtime verification

    AC9 が実際に live 環境で証明できる claim を過大化しない。

    historical #2119/#2137 に durable scope marker が存在しないなら、それだけで live exact coverage を証明したことにしない。

    live runtime verification は discovery / identity / relation / main ancestry / fallback rejection 等の transport claim に限定し、exact coverage → disposition → Step 1 suppression の production E2E は、durable manifest producer を通った現実的な fixture / test path で証明する contract に分離すること。

    durable skill contract

    新しい pre-Step-1 disposition が impl-review-loop の公開 semantics を変えるなら、.claude/skills/impl-review-loop/SKILL.md が Allowed Paths から漏れたままにしない。

    コードと durable skill SSOT を一致させる。

    Issue contract の完成条件

    最終 #2699 は少なくとも以下を曖昧さなく持つこと。

    • Outcome
    • In Scope / Out of Scope
    • machine-readable evidence/coverage contract
    • durable snapshot producer と consumer の責務
    • legacy compatibility policy
    • existing 実装: impl-review-loop に already_satisfied terminal route を追加する #2607 already_satisfied との precedence
    • canonical implementation-scope normalization rule
    • multi-candidate resolution rule
    • cross-reference parsing semantics
    • decision-time freshness / rebind policy
    • disposition precedence
    • runtime verification applicability
    • Acceptance Criteria
    • baseline expectation 付き Verification Commands
    • 実際の変更範囲と一致する Allowed Paths
    • Stop Conditions
    • Required Design References

    AC と VC は 1:1 で検証意図が追跡できるようにする。

    既存テストで既に pass する behavior は # baseline-expect: pass、新規 behavior は原則 # baseline-expect: fail とし、baseline contract を偽装しない。

    自律ループ

    rewrite 後は必ず fresh body に対して canonical review を再実行する。

    semantic review が再度必要なら再実行する。

    SEMANTIC_REWRITE_CONSTRAINTS_V1.max_rewrite_attempts 等の bounded limit は遵守する。

    no-progress、hash 不変、finding 非減少等は prose で独自判定せず canonical router に従う。

    途中で一度 review が approve しても、rewrite 後の stale artifact を再利用しない。

    終了

    以下になるまで自律的に進める。

    • fresh deterministic/root review が approve
    • applicable な semantic review / join も approve
    • updated Issue body の fresh readback が成功
    • unresolved P0/P1 semantic blocker がない
    • implementation handoff 可能な contract になっている

    この状態になったら #2699 の refinement を終了する。

    impl-review-loop は起動しない。

    canonical skill が最終的に human_judgment_required または operator_intervention_required を返した場合のみ、その route を捏造せず停止し、以下だけを簡潔に報告する。

    • terminal route
    • unresolved blocker
    • 実行済み iteration / rewrite attempt
    • 最終 Issue body SHA
    • 次に人間が決める必要がある一点

    それ以外の途中承認は求めない。

    特に重要なのは、canonical Step 2 で旧 issue-reviewer を起動せず、semantic Step 2.5 の issue-design-reviewer だけは明示的に completion join する点です。これで現行スキル契約に沿いつつ、要求された「SubAgent を使い、完了を待つ」挙動になります。

  4. squne121 commented on Sep 21, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    • Cause: human_judgment_required
    • Issue: 実装: impl-review-loop intakeにevidence-based landing dispositionを実装する #2699
    • Semantic rewrite lane iteration: 3(SEMANTIC_REWRITE_CONSTRAINTS_V1.max_rewrite_attempts: 2 を超過)
    • Deterministic review(Step 2): 直近の fresh review で VERDICT: approve(body_sha256: sha256:38f41142e700250db145051c68cfc42150d369dee9812b9134e0431f6e0c05b8)
    • Semantic design review(Step 2.5): 4 回実施し、都度 findings を反映して rewrite。4 回目のレビューで、過去に一度修正したものと同一クラスの blocker(Disposition Precedence の分岐網羅漏れ)が別の分岐で再発したため、これ以上の自律 rewrite を継続せず停止する。

    これまでの経緯(4 iteration の要約)

    1. anchor comment(https://github.com/squne121/loop-protocol/issues/2699#issuecomment-5755952589)の P0-1/P0-2/P1/P2 findings を fresh investigation で再検証し、全面改訂した body を投入。durable scope snapshot producer(open-pr/scripts/open_pr.py への embedding)、既存 実装: impl-review-loop に already_satisfied terminal route を追加する #2607 already_satisfied との precedence 合成、canonical scope normalizer、multi-candidate resolution、cross-reference parsing semantics、freshness/TOCTOU rebind policy、AC9(→AC12)の narrowed runtime verification claim を追加。Allowed Paths 拡張(open-pr/scripts/open_pr.py 等 3 件)は read-only investigation が導出した exact path literal を authority_transport.produce 経由で bind した正規の scope 拡張。
    2. Step 2.5 semantic review で HIGH(markerless open/draft candidate の resume 判定未定義)、MEDIUM(canonical serialization のリスト順序非依存性未定義)、LOW(pr_head_sha の用途不明確)を検出 → 修正。
    3. Step 2.5 semantic review で HIGH(Legacy Compatibility Policy の「marker の有無に関わらず」という文言が Disposition Precedence と矛盾)、MEDIUM(directory-prefix 一致の誤マッチ)を検出 → 修正。
    4. Step 2.5 semantic review で BLOCKER(Disposition Precedence step5 の例示が Legacy Compatibility Policy / AC6 の reconciliation_required 規定と矛盾)、MEDIUM(closed-unmerged candidate と already_satisfied フォールバックの関係が曖昧)を検出 → 修正(step4b 新設等)。
    5. (今回、未修正) Step 2.5 semantic review で BLOCKER: Disposition Precedence が「marker 付き open/draft candidate で covered_exactly でない場合」と「merged qualified candidate で marker は存在するが covered_exactly でない場合(PR merge 後に Issue 側でスコープが拡張されたケース)」の 2 つの分岐を明示的にカバーしておらず、catch-all の step5(ordinary_dispatch_or_explicit_recovery)に暗黙的に落ちてしまう。これは Legacy Compatibility Policy の marker 付き open/draft 節が明記する reconciliation_required と矛盾する。AC5/AC6/AC10 のいずれもこの 2 ケースを検証対象として明示していない。

    Blockers

    • Disposition Precedence の未網羅分岐(blocker、requires_owner_choice: true): 以下 2 点を OWNER が明示的に決定する必要がある。
      1. marker 付き open/draft candidate で covered_exactly でない場合(marker 記録後に Issue 側でスコープが拡張された)の disposition を、Legacy Compatibility Policy の明文どおり reconciliation_required として Disposition Precedence に明示的な step(例: step4c)を追加するか。
      2. merged qualified candidate で marker は存在するが covered_exactly でない場合(PR merge 後に Issue 側でスコープが拡張された)をどう扱うか。reconciliation_required とするか、別の disposition を新設するか、あるいは既存 step5 の例示に明示的に含めるか。
      • いずれの決定も、対応する AC(AC5 または AC6 の拡張、あるいは新設 AC)と AC10 の fixture 網羅(scope expansion が open/draft 限定か merged も含むかの明記)へ反映が必要。

    現在の Issue body 状態

    • 最終 body_sha256: sha256:38f41142e700250db145051c68cfc42150d369dee9812b9134e0431f6e0c05b8
    • Deterministic review(Step 2): approve
    • Semantic review(Step 2.5): needs-fix(blocker 1 件、requires_owner_choice: true)
    • 上記 blocker 以外の P0/P1/P2(anchor comment 由来)はすべて body に反映済み。

    次に人間が決める必要がある一点

    marker 付き open/draft candidate の scope drift ケースと、merged + marker 付きだが非 exact coverage のケースを、Disposition Precedence 上でどう扱うか(reconciliation_required に統一するか、別 disposition を設けるか)を決定し、決定内容を Issue #2699 本文(Disposition Precedence / Legacy Compatibility Policy / 該当 AC)へ反映してから、issue-refinement-loop を再実行する。

  5. added 4 commits that reference this issue on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions