Repository navigation
fix: cleanup_exec.py の PR head OID 検証を squash merge に対応させる - #1344
Conversation
squash merge された PR は headRefOid(squash commit SHA)がローカルブランチの tip と一致しないため、verify_cleanup_authorization / verify_branch_only_cleanup_authorization が常に pr_head_oid_mismatch として 誤ブロックしていた。 - `_pr_state()` に `mergeCommit` フィールドを追加 - `merge_base..local_tip` の path-set に限定した内容比較で squash-equivalence を 判定する `_resolve_head_equivalence()` を追加し、両関数の HEAD_OID_MISMATCH 判定に組み込んだ - 非 squash merge / mergeCommit 欠落時は既存の厳密一致 fail-closed 挙動を維持 - `verified` dict に `head_equivalence_authorized` / `head_equivalence_mode` / `pr_merge_commit_oid` / `local_delta_paths_count` を additive に追加 (`head_oid_match` の既存意味論は変更していない) - `tests/codex/test_cleanup_exec_branch_only.py` に squash merge 回帰テスト (正常系・境界系)を追加 Closes #1337 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1344 closed). |
|
TEST |
|
TEST_VERDICT_MACHINE v1 Result: PARTIAL |
|
AC Results (Individual): AC1: SKIP (exit 4) - new squash merge test, expected baseline |
|
Verification Details: PR diff touches Allowed Paths only:
Existing Tests (AC3/AC4/AC5): PASS
New Tests (AC1/AC2/AC6-AC9): SKIP (exit code 4)
|
|
Contract Compliance: Issue #1337 Scope Delta explicitly notes: This verification confirms:
Final TEST_VERDICT: PARTIAL
|
|
TEST_VERDICT YAML: runtime_ac_results: verification_summary: |
squne121
left a comment
There was a problem hiding this comment.
test with backtickchar
squne121
left a comment
There was a problem hiding this comment.
PR Review Judge 判定
(前3件のコメントはレビュー投稿手順の技術検証中に誤って投稿されたテストコメントであり、本判定とは無関係です。以下が正式な判定です。)
- Linked Issue: #1337(Closes #1337 明記あり)
- Allowed Paths 遵守: scripts/agent-ops/cleanup_exec.py と tests/codex/test_cleanup_exec_branch_only.py の2ファイルのみ変更(git diff --name-status -M で独立再検証。rename無し、Allowed Paths外の混入無し)。
- CI: ci_verdict_summary.py --pr 1344 --expected-head-sha 6d0af72... の結果は status: all_pass(required checks全green、skip 5件は妥当)。
- テスト: 実際の worktree checkout(HEAD = PR head 6d0af72)上で pytest tests/codex/test_cleanup_exec_branch_only.py -q を独立実行し 39 passed を確認(self-report非依存の再実行)。
- AC1/AC2/AC6-AC9: 新規テスト実装をdiffで確認。_resolve_head_equivalence() が merge_base..local_tip のpath-set限定比較を行い、mergeCommit欠落・path-set外不一致・extra unmerged filesを正しくfail-closedにしている。Issue #1337のcontract-review初回REQUEST_CHANGESで指摘されたP0(full-tree比較禁止・path-set限定必須・head_oid_match意味論維持)が全て反映されている。
- AC3/AC4/AC5: 既存回帰テスト test_oid_mismatch_refused / test_oid_mismatch_verify_branch_only_returns_false が変更されず、非squash exact-oid経路は従来どおり維持(head_ref_oid == local_tip の早期returnパスを確認)。
- Schema Change: verified dictへの4 additiveフィールド + _pr_state() の mergeCommit フィールド追加。Schema Consumer Inventory記載あり、materialize_cleanup_contract.py は透過転送のみで影響なしとの説明をdiffでも確認(該当ファイル無変更)。
- Safety Claim: N/A(.claude/skills/、.github/workflows/、permission/sandbox系に非該当の内部ロジック+pytest)と判断根拠が妥当。
- PR body hygiene: 受け入れ条件の達成状況/検証コマンド結果/Allowed Paths 遵守 の正式見出しは無いが、Checksセクションに全9AC番号+検証コマンド+PASS根拠が記載されており実質的なAC coverageは充足。見出し名の不一致のみ(mechanical hygiene差分)。
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "6d0af72f104835c6e9c8aa2c63494482cd5b836d"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions:
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
blocking_merge_ready: true
mechanical: true
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: git_diff_name_status_find_renames_z
changed_files:- scripts/agent-ops/cleanup_exec.py
- tests/codex/test_cleanup_exec_branch_only.py
producer_role: review_subagent
worker_report_used_as_canonical: false
補足: Draft PRのため merge_ready は required_auto_actions 非空につきfalse。update_pr_body_hygiene はPR本文に正式見出しを追加する軽微な整形対応で、内容自体は既にChecksセクションに充足済み。
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "6d0af72f104835c6e9c8aa2c63494482cd5b836d"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests:
- "ci_verdict_summary.py の HEAD_SHA_NULL_SKIPPED_EXCLUDE_RULES に ("Check Japanese Content", "PR Body Japanese Check") を追加し、pull_request_review トリガー実行での job-level skip (head_sha=null) を false failed 判定にしない改修(今回は gh api で run-level head_sha 一致・両トリガーとも conclusion:success を独立確認し false positive と判断)"
allowed_paths_gate:
status: "ok"
producer_role: "review_subagent"
worker_report_used_as_canonical: false
changed_files_source: "git_diff_name_status_find_renames_z"
changed_files_count: 2
changed_files:- "scripts/agent-ops/cleanup_exec.py"
- "tests/codex/test_cleanup_exec_branch_only.py"
violations: []
contract_source_kind: "issue_body"
contract_source_id: "1337"
再検証サマリ
- PR本文:
## 受け入れ条件の達成状況/## 検証コマンド結果/## Allowed Paths 遵守見出しあり。AC1-AC9 全て[x]+ 根拠(該当テスト関数名)記載を確認。 - Mergeable:
MERGEABLE/CLEAN(Draft は非 blocker)。 - Allowed Paths gate:
allowed_paths_review_gate.pyを独立実行しstatus: ok、violations 0、changed files 2件(scripts/agent-ops/cleanup_exec.py,tests/codex/test_cleanup_exec_branch_only.py)が Issue #1337 contract の Allowed Paths と完全一致することを確認(gh pr diff --name-onlyでも同一)。 - CI:
ci_verdict_summary.pyは exit 10(PR Body Japanese Checkfailed 判定)を返したが、gh api actions/runsで両トリガー run(pull_requestrun 28748217348 /pull_request_reviewrun 28748134800)を直接確認した結果、両方とも run-levelhead_shaが現HEAD(6d0af72f...)と一致しconclusion: success。SKIPPED として現れたPR Body Japanese Checkjob はpull_request_reviewトリガー run 内の条件付き job-level skip(別 job であるPR Review Japanese Check (retrospective)がそちらでは実行される設計)であり、pull_requestトリガー run ではPR Body Japanese Checkjob 自体が success。スクリプトの除外allowlistに漏れがあるための false positive と判断し、他の全 required check(typecheck/lint/test/build/e2e/python-test/actionlint/check-hook-integrity 等)は SUCCESS。blocker としては扱わない。 - Schema Change Applicability:
schema_changeとして明記、Schema Consumer Inventory あり(additive フィールドのみ、既存 consumer は更新不要と根拠付きで記載)。 - Safety Claim Matrix: N/A 根拠明記(safety-sensitive パス非該当)。
判定REQUEST_CHANGES。 方向性は正しいです。#1337 の主目的である「squash merge 済み PR で ただし、 P1: non-squash merge にも fallback が入り得る
#1337 は「非 squash merge(fast-forward / merge commit)では既存の厳密な 修正要求: fallback 前に # 推奨方針
# 1. git cat-file -e <merge_oid>^{commit}
# 2. git rev-list --parents -n 1 <merge_oid>
# 3. parent が 1 個の squash-equivalence candidate のみ fallback 対象にする
# 4. parent が 2 個以上の通常 merge commit は fail-closed: pr_head_oid_mismatchこれにより、「mergeCommit があるから squash 相当として比較する」という過剰許可を防げます。 P1: path set の起点が current default branch 依存現在の 通常ケースでは fork point が返るため動きますが、cleanup は削除認可なので、履歴が進んだ default branch、rebase/rewind、複数 merge-base のような形状に対して曖昧です。 修正要求: squash commit の parent を取得し、 parents = _commit_parents(project_root, merge_oid, deadline)
if len(parents) != 1:
return False, additive
squash_parent = parents[0]
bases = _merge_bases(project_root, squash_parent, local_tip, deadline)
if len(bases) != 1:
return False, additive#1337 の anchor comment でも、full-tree 比較は禁止、local branch が導入した全 path set を列挙し、その全 path について P1: branch-only squash-equivalence のテストが薄い実装は しかし追加テストは、squash-equivalence の正常系・不一致・extra file・missing mergeCommit・additive fields を 通常 worktree cleanup 側で確認しているだけです。 既存の branch-only テストは OID mismatch の fail-closed を確認していますが、 #1337 の AC4 は、branch-only cleanup 経路にも AC1/AC2 と同等の squash merge 対応を要求しています。さらに #1196/#1206 は branch-only lane を 修正要求: 以下を追加してください。 uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_verify_branch_only_accepts_squash_merge_path_scoped_match
uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_verify_branch_only_rejects_squash_merge_content_mismatch
uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_branch_only_run_deletes_branch_after_squash_equivalencebranch-only は destructive path なので、通常 path の helper coverage だけでは不足です。 P1:
|
…path比較に硬化する OWNER の敵対的レビュー (PR #1344) の P1/P2 指摘に対応する。 - _resolve_head_equivalence(): merge commit object の存在確認と parent 数検証 (parent==1 のみ fallback 対象、2parent 以上の通常 merge commit は fail-closed) を fallback 前に追加 - path-set 起点を current default branch でなく squash commit の parent 基準の merge-base に変更し、複数 merge-base の場合は fail-closed にする - _squash_equivalence_path_set() を `git diff --name-only -z` に、内容一致判定を `git diff --quiet --no-ext-diff` (0/1/>1 で fail-closed) に変更 - 厳密 OID 一致時は head_equivalence_authorized: false / head_equivalence_mode: exact_oid に統一 - branch-only squash-equivalence の正常系・拒否系・削除確認テストを追加 (TestBranchOnlySquashEquivalence) - merge commit object missing / merge-base git error / 非 squash 2-parent merge commit の fail-closed 回帰テストを追加 Closes #1337
|
TEST_VERDICT: PASS - All 9 ACs and all 6 new regression tests verified to PASS. PR head 65bd360 confirmed at worktree. Mergeable=MERGEABLE. Allowed Paths constraint satisfied. |
squne121
left a comment
There was a problem hiding this comment.
PR Review Judge 判定(iteration 1 再審査 / OWNER adversarial review への fix_delta 対応確認)
OWNER の P1×4 + P2×2 それぞれを head 65bd360 の実 diff・実テスト実行で独立検証した。
- P1(1) non-squash fallback:
_commit_object_exists()(cat-file -e <oid>^{commit}) +_commit_parents()(rev-list --parents -n1) を追加し、parent数が1でない(2+ parent の通常 merge commit)は squash-equivalence に入らず fail-closed。test_non_squash_merge_commit_oid_mismatch_rejects_even_if_paths_matchは実際にgit merge --no-ffで本物の2-parent merge commitを作り、feature.txt内容が一致していても拒否されることを確認しており、trivialでない。反映済み。 - P1(2) path-set起点:
_merge_bases()がmerge-base --all <squash_parent> <local_tip>を使い、squash commitの親(_commit_parentsの[0])を起点にし、複数merge-baseはfail-closed。current default branch依存を解消。test_squash_merge_git_diff_error_rejectsで_merge_basesがNoneを返すケース(git error相当)もfail-closedを確認。反映済み。 - P1(3) branch-only系テストの薄さ:
TestBranchOnlySquashEquivalenceクラスでverify_branch_only_cleanup_authorizationを直接呼ぶ正常系・拒否系に加え、test_branch_only_run_deletes_branch_after_squash_equivalenceは実際にrun()を呼び、実 git branch削除(git rev-parse --verify refs/heads/<branch>が失敗することを確認)まで検証する destructive path のend-to-endテスト。superficialでない。反映済み。 - P1(4) -z / --quiet --no-ext-diff:
_squash_equivalence_path_set()はgit diff --name-only -z+ NUL split、_squash_content_matches()はgit diff --quiet --no-ext-diffを使用し returncode 0/1/その他(fail-closed)を明示的に分岐。反映済み。 - P2(1) exact_oid の意味論: exact match時は
head_equivalence_authorized=False/head_equivalence_mode="exact_oid"に統一(OWNER提案の前者案採用)。test_verified_dict_contains_additive_head_equivalence_fieldsでhead_oid_match=False(squash-equivalence時)と非混同を確認。反映済み。 - P2(2) missing object / git error / non-squash のテスト不足:
test_squash_merge_merge_commit_object_missing_rejects(存在しないSHAでcat-file失敗→拒否)、test_squash_merge_git_diff_error_rejects(_merge_basesをNoneにpatch→拒否)、test_non_squash_merge_commit_oid_mismatch_rejects_even_if_paths_match(本物の2-parent merge commit)の3件を追加。反映済み。
独立再実行
uv run pytest tests/codex/test_cleanup_exec_branch_only.py -q(.claude/worktrees/issue-1337-cleanup-exec-squash-merge、HEAD=65bd3609、self-report非依存で再実行)→ 45 passed(既存39 + 新規6)。ci_verdict_summary.py --pr 1344 --expected-head-sha 65bd3609...→status: all_pass、head_sha一致、skip 5件は既知の除外対象のみ。allowed_paths_review_gate.pyを独立実行(issue #1337 contractのsha256/fingerprintをissue本文から再計算し binding) →status: ok、violations 0、changed files 2件が Allowed Paths と完全一致(rename無し)。ruff checkでtests/codex/test_cleanup_exec_branch_only.pyに F401/E402 計8件検出したが、base(main)時点の同ファイルでも同一8件が既存していることを確認済み(このPRによる新規混入ではない、CI lintも実際にgreen)。
その他
- PR本文:
## 受け入れ条件の達成状況(AC1-9全て[x]+根拠テスト名) /## 検証コマンド結果/## Allowed Paths 遵守/## Schema Change Applicability(schema_change) /## Schema Consumer Inventory(additiveのみ、既存consumer更新不要の根拠あり) /## Safety Claim Matrix(N/A、根拠明記) すべて具備。 - Mergeable:
MERGEABLE/CLEAN。Draft状態だが blocker ではない。 - Closes #1337 明記あり。
blocker なし。OWNERの6項目の修正要求は全て実コード・実テストで裏付けられており、rubber stamp ではなく実体験証を伴う独立確認の結果としてAPPROVEとする。
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "65bd3609ce0375a59e86b2fded3ed849db801e1d"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: "ok"
producer_role: "review_subagent"
worker_report_used_as_canonical: false
changed_files_source: "git_diff_name_status_find_renames_z"
changed_files_count: 2
changed_files:
- "scripts/agent-ops/cleanup_exec.py"
- "tests/codex/test_cleanup_exec_branch_only.py"
violations: []
contract_source_kind: "issue_body"
contract_source_id: "1337"
Summary
verify_cleanup_authorization/verify_branch_only_cleanup_authorizationが常にpr_head_oid_mismatchを返して worktree / branch 削除を誤ブロックしていた問題を修正した。headRefOid(=squash commit の新規 SHA)がローカルブランチ tip と一致しないため、GitHub 上で正しくマージ済みの PR でも既存の厳密一致判定に常に失敗していた。gh pr view --json mergeCommitを追加取得し、merge_base..local_tipの path-set に限定した内容比較で「ブランチ tip の内容が squash 済みコンテンツと一致するか」を判定する_resolve_head_equivalence()を新設し、両関数の HEAD_OID_MISMATCH 判定に組み込んだ。mergeCommit欠落時は、既存の厳密一致 fail-closed 挙動をそのまま維持する(実装: post-merge-cleanup の branch-only resume lane を cleanup_exec に追加する #1196 が確立した契約の supersede ではない、additive 拡張)。受け入れ条件の達成状況
merge_base..local_tipの path set に限定した範囲でブランチ tip の内容が merge 済みコンテンツと一致する場合、verify_cleanup_authorizationがpr_head_oid_mismatchを返さず認可されることをtest_verify_cleanup_authorization_accepts_squash_merge_path_scoped_matchで確認・PASS。pr_head_oid_mismatchを返すことをtest_verify_cleanup_authorization_rejects_squash_merge_content_mismatchで確認・PASS。headRefOidがローカルブランチ tip と完全一致しない場合、既存どおりtest_oid_mismatch_refusedが拒否として PASS し続けることを確認(既存の厳密な OID 一致判定を破壊していない、pre-existing regression test)。verify_branch_only_cleanup_authorization(branch-only cleanup 経路)にも AC1/AC2 と同等の squash merge 対応が適用され、既存のtest_oid_mismatch_verify_branch_only_returns_falseが引き続き PASS することを確認(pre-existing regression test)。tests/codex/test_cleanup_exec_branch_only.pyの全 39 件が PASS することを確認(既存テストを破壊していない)。test_squash_merge_unrelated_base_change_does_not_false_matchで確認・PASS。pr_head_oid_mismatchとして拒否されることをtest_squash_merge_rejects_extra_unmerged_local_filesで確認・PASS。gh pr view --json mergeCommitの戻り値が missing または null の場合、squash-equivalence の fallback 判定には入らず既存の fail-closed 拒否挙動が維持されることをtest_squash_merge_missing_merge_commit_falls_back_to_rejectで確認・PASS。verifieddict にhead_equivalence_authorized/head_equivalence_mode/pr_merge_commit_oid/local_delta_paths_countの additive フィールドが含まれ、既存のhead_oid_matchの意味論が変更されていないことをtest_verified_dict_contains_additive_head_equivalence_fieldsで確認・PASS。検証コマンド結果
Allowed Paths 遵守
scripts/agent-ops/cleanup_exec.pytests/codex/test_cleanup_exec_branch_only.pygit diff --name-only main...HEADで確認済み、Allowed Paths 外の変更は無い)。Checks
以下の検証コマンドをすべて実行し、全件 PASS を確認した。
uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_verify_cleanup_authorization_accepts_squash_merge_path_scoped_match(AC1)uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_verify_cleanup_authorization_rejects_squash_merge_content_mismatch(AC2)uv run pytest tests/codex/test_cleanup_exec_branch_only.py -k test_oid_mismatch_refused(AC3)uv run pytest tests/codex/test_cleanup_exec_branch_only.py -k test_oid_mismatch_verify_branch_only_returns_false(AC4)uv run pytest tests/codex/test_cleanup_exec_branch_only.py— 全 39 件 PASS (AC5)uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_squash_merge_unrelated_base_change_does_not_false_match(AC6)uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_squash_merge_rejects_extra_unmerged_local_files(AC7)uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_squash_merge_missing_merge_commit_falls_back_to_reject(AC8)uv run pytest tests/codex/test_cleanup_exec_branch_only.py::test_verified_dict_contains_additive_head_equivalence_fields(AC9)pnpm typecheck/pnpm lint/pnpm test(92 files, 1399 tests PASS)/pnpm builduv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(21 件 PASS)Schema Change Applicability
verify_cleanup_authorization/verify_branch_only_cleanup_authorizationが返すverifieddict、および_pr_state()が取得するgh pr view --jsonフィールドSchema Consumer Inventory
scripts/agent-ops/materialize_cleanup_contract.pyverify_cleanup_authorizationの戻り値を dict として transparently 転送するのみで、追加キーの有無に依存するロジックはないscripts/agent-ops/cleanup_exec.py(run()/_result()/_branch_only_result())verifieddict に含めて返すtests/codex/test_cleanup_exec_branch_only.pySafety Claim Matrix
N/A — reason: 変更対象(
scripts/agent-ops/cleanup_exec.pyの内部認可ロジック)は transport / permission / sandbox / auth / mcp /.claude/skills//.github/workflows/のいずれにも該当しない純粋な pytest unit test で完結するロジック修正であり、safety-sensitive パスに該当しない。既存の fail-closed 経路(mergeCommit 欠落・path-set 内容不一致・非 squash merge)は本 PR の回帰テスト(AC3/AC4/AC6-AC8)でそのまま維持されていることを確認済み。Notes
not_applicable(Issue contract どおり、pytest unit test のみで AC が成立するため実プロセス起動・実ネットワーク通信を要する動作検証は不要).claude/skills/post-merge-cleanup/SKILL.mdの呼び出し手順変更、他 skill のロジック変更、.github/workflows/*の変更、.github/ci/python-test-plan.jsonへの新規ファイル登録(既存登録済みファイルへの追記のため不要)