Repository navigation
fix: impl-review-loop の irrelevant sibling cross-reference による qualification 前 freshness 誤停止を解消する - #2768
Conversation
…ication 前 freshness 誤停止を解消する (#2767) research Issue #2761 の残余リスク (PR #2758 の bounded carve-out 後も、fresh negative qualification 成立後の irrelevant sibling candidate の transport failure / head drift が current target の reconciliation_required を誤って 誘発する) を解消する。 - collect_candidate_inputs(): 各候補のscope_coverage確定直後に qualified_irrelevant_sibling フラグを算出し、merged候補のmain-ancestry compare をqualified-irrelevantな候補ではskip-by-constructionする。 - _candidate_errors(): merged_candidate_main_ancestry_unverified チェックを qualified_irrelevant_sibling 候補には適用しない。 - _live_freshness_reference(): decision-time の gh pr view fetchに body/closingIssuesReferences を追加し、qualified_irrelevant_sibling 候補の適格性を decision-time の live データから独立に再導出する (byte-for-byte一致を要求しない)。再確認できた irrelevant sibling は freshness match の identity 要求から除外し、その transport failure / head drift が current target の freshness_rebind_failed を誘発しないよ うにする。 - _apply_live_candidate_qualification_updates(): decision-time の live データが current-target authority (closingIssuesReferences に current target を含む) を示す場合、candidateのprovenanceを closing_relation に昇格し、既存の closing-priority disposition logic に委ねる (bespoke な un-exclusion 分岐を追加しない)。 pr_head_sha は negative-qualification / freshness authority に一切昇格 させていない (既存の invariant を維持)。PR #2758 の bounded carve-out (qualified_candidate_conflict のカウント) には触れていない。 Refs #2761 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2768 closed). |
pr-review-judge verdictverdict: APPROVE
reviewed_head_sha: "b6653ed5a5d6945ae602eaba953bb00b16407413"
blockers: []
warnings: []Live mergeability at time of this comment: mergeable=MERGEABLE, merge_state_status=CLEAN. impl-review-loop terminated with route=approved / IMPL_REVIEW_LOOP_RESULT_V1.status=draft_pr_ready. PR is Draft — human review/mark-ready and merge decision remain with a human maintainer per repository policy. |
結論PR #2768 は 個人趣味開発という前提なら、新しい framework・schema・runtime harness を増やす必要はありません。既存 helper を使った小さな条件修正+regression 2本程度で閉じられる問題です。 [PR #2768](https://github.com/squne121/loop-protocol/pull/2768?utm_source=chatgpt.com) Findings
Issue #2761 の AC5 と Issue #2767 の AC3 は明示的に、
場合を fail-closed のまま維持するとしています。 ところが current head [implementation_landed_evidence.py L771-L785]( if c_payload is None or live_issue_body is None:
...
excluded_candidate_numbers.add(number)
continueつまり、 となります。 これは Issue #2761 が要求した ではなく、authority materialization が失敗した unknown candidate を irrelevant 扱いする挙動です。 特に悪いケースは、collection 後に sibling PR が current target の authority に変化したものの、その瞬間の decision-time 修正は小さくできます。 GitHub CLI は
同じ箇所で、 live_refs = c_payload.get("closingIssuesReferences") or []となっています。 したがって
でも、「確認できなかった」ではなく「closing relation は存在しない」と解釈されます。 その後 body が sibling marker と解釈できれば、 still_irrelevant = (not live_closing) and ...が成立し、freshness から除外できます。 Issue #2761 AC5 の「
既存 helper sibling_light_fetch_fails: bool = Falseがあり、decision-time の light しかし current test file 全体を確認した範囲では、 PR 本文で AC3 の evidence とされている
は、その名前から紛らわしいものの、docstring 上も実装上も collection-time の最初の full [collection-time failure test]( ここは既存 helper をそのまま使って、 run, _ = _build_pipeline_run(sibling_light_fetch_fails=True)
result = resolve_landing_disposition_with_freshness_rebind(...)
assert result["decision_time_rebind"]["status"] == "stale"
assert result["landing_disposition"]["disposition"] == "reconciliation_required"
assert result["landing_disposition"]["reason_codes"] == ["freshness_rebind_failed"]相当を追加すれば十分です。さらに
Issue #2767 AC2 と PR の scope marker は closed-unmerged sibling の head identity drift まで対象にしています。 全 lifecycle をループする 一方、実際に SHA を変えている regression は、 [head drift regression L1620-L1640](https://github.com/squne121/loop-protocol/blob/565758d7c52045ab8c3d4914961d5bae4381adb6/.claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py?utm_source=chatgpt.com#L1620-L1640)
実装上
PR 本文では Schema Change Applicability を
としています。 ただし実際には したがって「完全な module-internal」は不正確です。ただし、現在の 良い部分collection 時点で durable marker を解析した直後に qualification し、merged irrelevant sibling の ancestry compare 自体を skip-by-construction にしたのは適切です。 [collection qualification / ancestry skip](
また、decision-time body が collection-time body とバイト一致しなくても、最新 body を改めて parse して sibling identity を判定する方針も正しいです。 GitHub の compare endpoint で current head / CI以前の その後の2 commit は main の merge による task-context 系変更で、現在 main に対する PR の実効差分は依然として今回の3ファイルだけです。したがって stale review 自体をコード blocker にはしませんが、current-head review evidence としては更新が必要です。 CI は確認時点でほぼ成功しており、 最小の修正方針この PR に必要なのは P1 の authority boundary を直すことです。新規 Issue・新規 harness・新規 security subsystem は不要です。
今回のスコープに #2739 の timeline pagination や追加 hardening を持ち込む必要はありません。 P1 はセキュリティ強化ではなく、PR自身が掲げている freshness authority / correctness の中核なので、ここだけはマージ前に修正する価値があります。 |
|
確認した限り、別 Issue を先に起票するより、PR #2768 をそのまま再開して #2767 の AC3/AC6 未充足として直すのが適切です。対象コメントの P1 は独立した新スコープではなく、Issue #2767 が明示している「decision-time live body/detail 取得失敗・ 現在の状態では、PR #2768 は Draft / open / mergeable、current head は また、現在の実効 PR diff は Issue #2767 の Allowed Paths と一致する3ファイルだけで、review thread もありません。対象指摘は review thread ではなくトップレベル PR コメントなので、これを明示的な新しい 推奨する処理順は次のとおりです。
以下を、そのまま既に auto mode で起動している Claude Code に渡せます。
対象:
目的: 通常の人間承認・続行確認は求めないこと。 ただし PR の merge 自体は実行しない。 最初に必ず live state を再取得する以下は開始時点の観測値であり、authority として固定せず live readback で確認すること。
開始時に PR head、base/main、mergeability、draft state、PR comments、Issue #2767 body、current diff、current CI を fresh に再取得し、LOOP_STATE を current head に bind すること。 上記 target comment impl-review-loop を canonical に実行する
orchestrator 自身が実装・レビューを一人で代替せず、skill が規定する SubAgent を使用すること。 最低限:
を役割分離して使用すること。 各 SubAgent を起動したら、その SubAgent の作業が terminal な構造化結果を返すまで必ず待つこと。 SubAgent の途中結果を推測で補完しない。 Issue #2767 が禁じている nested SubAgent delegation と、orchestrator が canonical worker/test/reviewer SubAgent を使うことを混同しないこと。 今回の blocking fix_deltatarget comment の P1 を blocker として扱うこと。 P1-1: decision-time candidate fetch failure が fail-open になっているcurrent implementation の これは禁止。 原則は:
とすること。 decision-time に candidate PR の live authority を再取得できなければ、その candidate は「still irrelevant」ではなく unknown。 fetch / JSON parse failure の candidate を P1-2:
|
…dy-closing authority を unknown として fail-closed 化する PR #2768 レビュー (research Issue #2761 の残余リスク) 指摘を修正する。 - `_live_freshness_reference()`: 収集時に qualified_irrelevant_sibling とされた 候補の decision-time re-fetch が transport/parse 失敗した場合、これまでは 無条件に `excluded_candidate_numbers` へ追加し fail-open していた (P1-1)。fetch 失敗は "still irrelevant" ではなく unknown として扱い、 bounded retry を経ても再確認できなければ reconciliation_required / freshness_rebind_failed になるよう修正した。 - `closingIssuesReferences` / `body` が missing/None/wrong-type の場合を `[] や ""` と同一視せず、authority 未確認として区別した (P1-2)。 - 上記いずれの unconfirmed ケースも、既存の headRefOid/mergeCommit 由来の identity が non-None のままだと ok=False に反映されない抜け穴があったため、 `unconfirmed_qualified_irrelevant_numbers` を新設し ok 判定に独立して 組み込んだ。 - decision-time transport failure (P2-1)、body/closingIssuesReferences の missing/None/invalid-type境界 (P2-2)、closed-unmerged sibling の head drift (P2-3) の regression test を追加した。 修正前の実装でこれらの新規テストが失敗することを確認した上で production code を修正した (TDD 順序)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
pr-review-judge verdict対象コメント #2768 (comment) のP1/P2 blockerをfix_deltaとして反映し、impl-review-loopを再実行した。 修正内容(head 805bf79):
独立検証: test-runner が同一headをcheckoutし44+9+26 tests PASS、ruff PASS、Allowed Paths適合を確認。 verdict: APPROVE
reviewed_head_sha: "805bf7909f37d01cc437d6678010c9666bc9b734"
blockers: []
warnings: []Live mergeability at time of this comment: mergeable=MERGEABLE, mergeStateStatus=CLEAN, isDraft=true |
Summary
research Issue #2761 が特定した残余リスク(PR #2758 の bounded carve-out 適用後も、fresh に qualified-irrelevant と判定された sibling candidate の transport failure / head drift が current target Issue の
reconciliation_requiredを誤って誘発する構造的欠陥)を解消する。.claude/skills/impl-review-loop/scripts/implementation_landed_evidence.pyの3箇所を修正した。collect_candidate_inputs(): 各候補のscope_coverage確定直後にqualified_irrelevant_siblingフラグを算出し、merged 候補の main-ancestry compare(gh api .../compare/{merge_oid}...main)を qualified-irrelevant な候補では skip-by-construction する(無駄な transport call 自体を発行しない)。_candidate_errors():merged_candidate_main_ancestry_unverifiedチェックをqualified_irrelevant_sibling候補には適用しない(skip-by-construction で未取得のままの ancestry を fail 理由にしない)。_live_freshness_reference()/_apply_live_candidate_qualification_updates()(新設 helper): decision-time のgh pr viewfetch にbody,closingIssuesReferencesを追加し、qualified_irrelevant_sibling 候補の適格性を decision-time の live データから独立に再導出する(AC1: collection-time の body とのバイト一致は要求しない)。再確認できた irrelevant sibling は freshness match の identity 要求から除外し、その transport failure / head drift が current target のfreshness_rebind_failedを誘発しないようにする。live データが current-target authority(closingIssuesReferencesに current target を含む)を示す場合は、candidate のprovenanceをclosing_relationに昇格し、既存の closing-priority disposition logic にそのまま委ねる(bespoke な un-exclusion 分岐は追加しない)。AC 達成状況
coverage_from_pr_body()経由)と liveclosingIssuesReferencesに基づいて fresh negative qualification が成立する。collection-time body とのバイト一致は要求しない(test_freshness_rebind_reconfirms_irrelevant_sibling_from_changed_decision_time_bodyで検証)。test_freshness_rebind_open_draft_sibling_head_drift_does_not_fail_target_freshness)、merged sibling の main ancestry compare transport failure(test_collect_candidate_inputs_skips_ancestry_compare_for_qualified_irrelevant_merged_sibling)は current target のfreshness_rebind_failed/reconciliation_requiredを引き起こさない。test_collect_candidate_inputs_sibling_live_body_fetch_failure_stays_fail_closed)、closing_relation candidate の identity mismatch(既存test_closing_relation_identity_mismatch_stays_reconciliation_required)、markerless candidate(test_freshness_rebind_markerless_legacy_sibling_never_enters_carve_out_path)、compound marker error(test_collect_candidate_inputs_compound_marker_error_sibling_is_not_qualified_irrelevant)は引き続き fail-closed。pr_head_shaは negative qualification / freshness authority のいずれにも一切昇格させていない(下記 Safety Claim Matrix 参照)。test_collect_candidate_inputs_production_shaped_2727_sibling_cross_references_excluded(test_implementation_landed_intake_integration.py)を拡張し、build_intake_capsule._collect_implementation_landed_evidence()経由でresolve_landing_disposition_with_freshness_rebind() -> derive_landing_disposition() -> apply_already_satisfied_precedence()の full chain を検証、かつ ancestry compare が一切呼ばれないことを明示的に assert する行を追加した。追加した regression test(12 シナリオ)
test_implementation_landed_evidence.pyに以下を追加(既存 helper・命名規約を踏襲、新規ファイルは作成していない):1-4.
test_freshness_rebind_irrelevant_sibling_across_all_lifecycles_does_not_block_target— open/draft/merged/closed_unmerged の qualified-irrelevant sibling が current target のimplementation_already_landedを妨げないことをループ検証。merged sibling の ancestry compare が呼ばれないことも assert。5.
test_collect_candidate_inputs_skips_ancestry_compare_for_qualified_irrelevant_merged_sibling— merged irrelevant sibling の ancestry compare が skip-by-construction されること、evidence が valid のままであることを検証。6.
test_collect_candidate_inputs_sibling_live_body_fetch_failure_stays_fail_closed— sibling 自身の初回 detail fetch 失敗は既存どおり fail-closed のままであることを回帰確認。7.
test_freshness_rebind_reconfirms_irrelevant_sibling_from_changed_decision_time_body— collection-time と decision-time で body が変化しても、両方が独立に identity-mismatch-alone に再導出されれば qualification が成立すること(バイト一致不要)を検証。8.
test_freshness_rebind_sibling_now_showing_current_target_authority_is_not_excluded— decision-time の liveclosingIssuesReferencesが current target を指すようになった場合、carve-out が適用されず既存の closing-relation 処理(fail-closed)に委ねられることを検証。9.
test_freshness_rebind_markerless_legacy_sibling_never_enters_carve_out_path— markerless legacy candidate が carve-out の対象にならないことの回帰確認。10.
test_collect_candidate_inputs_compound_marker_error_sibling_is_not_qualified_irrelevant— identity mismatch + 別の marker error(複合エラー)は carve-out 対象にならず、ancestry compare もスキップされないことを検証。11.
test_freshness_rebind_open_draft_sibling_head_drift_does_not_fail_target_freshness— open/draft sibling の head drift が current target の freshness を壊さないことを検証。12.
test_collect_candidate_inputs_production_shaped_2727_sibling_cross_references_excluded(test_implementation_landed_intake_integration.py、既存テストを拡張)—#2727incident 実形の production-shaped fixture(build_scope_coverage_marker()/render_scope_coverage_marker()で生成した実際のマーカーテキスト)を用い、build_intake_capsule._collect_implementation_landed_evidence()経由で full chain を検証し、ancestry compare が一度も呼ばれないことを明示的に assert する行を追加した。Checks
追加で、影響範囲確認のため以下も実行し全て PASS を確認した(Allowed Paths 外だが read-only 実行):
Runtime Verification Applicability:
not_applicable(Issue 本文どおり、静的 pytest のみで完結)。Allowed Paths 準拠
変更ファイルは Issue #2767 の Allowed Paths と完全一致している(3ファイルのみ、超過なし):
.claude/skills/impl-review-loop/scripts/implementation_landed_evidence.py.claude/skills/impl-review-loop/tests/test_implementation_landed_evidence.py.claude/skills/impl-review-loop/tests/test_implementation_landed_intake_integration.pySchema Change Applicability
qualified_irrelevant_siblingは candidate dict に載る additive な候補メタデータであり、build_intake_capsule経由で intake artifact に serialize されうる(モジュール内部限定の分類フラグではない)。ただしIMPLEMENTATION_LANDED_EVIDENCE_V1/IMPLEMENTATION_SCOPE_COVERAGE_V1は closed key-set を強制するスキーマ定義ではなく、derive_landing_disposition()の戻り値契約(disposition/reason_codes/candidate)やIMPLEMENTATION_LANDED_EVIDENCE_V1のトップレベルキー集合、既存 consumer 契約(route_loop_verdict_v2.py/adjudicate_vc_result.py等)はいずれも破壊していない。新しい schema registry・新 schema は追加していない。Schema Consumer Inventory
N/A
reason: not_schema_change のため対象外。
Safety Claim Matrix
pr_head_shaは negative qualification / freshness authority のいずれにも一切使用・昇格しない(既存 invariant の維持)_is_irrelevant_cross_reference()/_live_freshness_reference()/_apply_live_candidate_qualification_updates()はいずれもpr_head_shaを参照せずscope_coverage/closingIssuesReferencesのみを qualification 入力とする(コード上確認可能)materialization_failures/contradictory/reconciliation_required)を維持するtest_collect_candidate_inputs_sibling_live_body_fetch_failure_stays_fail_closedclosing_relationへ昇格)は、collection 時点で ancestry を未取得のままだと fail-closed のまま(merged_candidate_main_ancestry_unverified等)になりうるtest_freshness_rebind_sibling_now_showing_current_target_authority_is_not_excludedqualified_candidate_conflictのカウント処理)には変更を加えていないtest_2727_incident_shape_two_sibling_cross_references_do_not_conflict/test_valid_non_closing_candidate_survives_sibling_cross_reference_exclusion(既存テスト、無変更で PASS)Notes
本 PR は research Issue #2761 の残余リスクに対する follow-up 実装である。