Repository navigation
feat(#1196): branch-only cleanup lane in cleanup_exec - #1206
Conversation
Adds `verify_branch_only_cleanup_authorization()` and `_perform_branch_only()` to handle partial-cleanup state where the worktree has been removed from disk and git catalog but the local branch still exists. Branch-only lane is triggered from `run()` only when `verify_cleanup_authorization()` returns `WORKTREE_NOT_IN_CATALOG`. `materialize_cleanup_contract` cannot reach the branch-only verifier. Five conditions (A-E) must all pass plus full PR authorization before `git branch -D` is executed via internal subprocess. New reason codes: worktree_still_in_catalog, branch_checked_out_in_worktree, local_branch_missing, branch_only_force_delete_denied, branch_only_materialize_denied. New test file: tests/codex/test_cleanup_exec_branch_only.py Closes #1196
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1206/ The preview will be removed when this PR is closed. |
|
test |
PR Review Verdict: REQUEST_CHANGESThis comment is a test with newlines. |
PR レビュー判定: REQUEST_CHANGESブロッカーB1: ci/python-test FAILED - test_worktree_scope_guard.py::test_cleanup_exec_refuses_worktree_not_in_catalog が regression。期待 reason_code=worktree_not_in_catalog、実際=branch_checked_out_in_worktree。AC8 不合格。 B2: Check Japanese Content FAILED - 4 prose blocks が per-block 日本語比率 0.1 未満。 Allowed Paths Gate: ok変更ファイル scripts/agent-ops/cleanup_exec.py と tests/codex/test_cleanup_exec_branch_only.py はいずれも Allowed Paths 内。 CIci (python-test): FAILED |
|
LOOP_VERDICT_V2: |
…_out_in_worktree WORKTREE_NOT_IN_CATALOG 後に branch-only lane が条件 D(同 branch の別 worktree 存在)を 検出して branch_checked_out_in_worktree を返す新しい動作に合わせてテストを更新する。
|
test |
Review Result: REQUEST_CHANGES - B1: python-test ci_test_selection artifact FAILURE (main=SUCCESS, PR=FAILURE, introduced regression). B2: node-backed-hook-tests selection artifact FAILURE (main=SUCCESS, PR=FAILURE). B3: PR Body Japanese Check FAILURE persists after iteration 1 fix. |
LOOP_VERDICT_V2schema_version: 2 allowed_paths_gate: ci_status: blockers:
ac_assessment: iteration: 2 |
…-plan.json CI の generate_ci_test_selection_artifact が changed but uncovered として tests/codex/test_cleanup_exec_branch_only.py を検出するため、 python-test-plan.json の targets に追加して B1/B2 CI 退行を解消する。
|
test-ping |
LOOP_VERDICT_V2verdict: APPROVE
reviewed_head_sha: "831e890b71847b59f5b5cab359865d1933c3a106"
merge_ready: false
mergeability:
mergeable: "UNKNOWN"
merge_state_status: "UNKNOWN"
note: "Draft PR - UNKNOWN は Draft 状態での通常挙動。CI 全 SUCCESS 確認済み。"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
schema: ALLOWED_PATHS_GATE_RESULT_V1
producer_role: review_subagent
worker_report_used_as_canonical: false
expected_contract_fingerprint: "sha256:d2ad5d103ca2af5c49849823929e851eb95f912e1de6e15a6ae0a187985ca00c"
contract_source_kind: issue_comment
contract_source_id: "https://github.com/squne121/loop-protocol/issues/1196#issuecomment-4815591296"
effective_allowed_paths:
- "scripts/agent-ops/cleanup_exec.py"
- "tests/codex/test_cleanup_exec_branch_only.py"
- ".claude/hooks/tests/test_worktree_scope_guard.py"
- ".github/ci/python-test-plan.json"
changed_files:
- ".claude/hooks/tests/test_worktree_scope_guard.py"
- ".github/ci/python-test-plan.json"
- "scripts/agent-ops/cleanup_exec.py"
- "tests/codex/test_cleanup_exec_branch_only.py"
violations: []
ci_evidence:
schema: CI_VERDICT_SUMMARY_V1
status: all_pass
head_sha: "831e890b71847b59f5b5cab359865d1933c3a106"
head_sha_match: true
run_id: 28284064543
jobs_pass:
- typecheck
- lint
- build
- test
- e2e
- python-test
- node-backed-hook-tests
- ci-verdict-summary
- check-hook-integrity
- actionlint
- "PR Body Japanese Check (run 28284292670)"
ac_coverage:
AC1:
status: pass
evidence: "TestNormalCleanup: 4 tests PASS"
AC2:
status: pass
evidence: "TestBranchOnlyCandidate: 4 tests PASS"
AC3:
status: pass
evidence: "TestOidMismatch: 2 tests PASS"
AC4:
status: pass
evidence: "TestPathConstraint: 2 tests PASS"
AC5:
status: pass
evidence: "TestCrossRepo: 4 tests PASS"
AC6:
status: pass
evidence: "TestAbsentAfterRemoval: 3 tests PASS"
AC7:
status: pass
evidence: "TestForceDelete: 5 tests PASS - git branch -D confirmed"
AC8:
status: pass
evidence: "CI python-test + check-hook-integrity PASS"
AC9:
status: pass
evidence: "TestCliShape: 3 tests PASS - no new flags"
isolation_check:
verify_cleanup_authorization_unchanged: true
materialize_cannot_reach_branch_only: true
schema_change_applicability: not_schema_change
safety_claim_matrix:
applicable: false
note: ".claude/hooks/tests/ は hook 本体未変更。check-hook-integrity PASS。OWNER ANCHOR_SCOPE_REFRAME_V1 承認済み"判定根拠全 AC (AC1-AC9) 実装確認。CI 全 required job SUCCESS (head SHA 831e890 一致)。Allowed Paths 変更 4 ファイル全て有効範囲内 (contract + ANCHOR_SCOPE_REFRAME_V1 x2)。verify_cleanup_authorization() は未変更で materialize 分離を維持。merge_ready: false は Draft PR + UNKNOWN mergeability によるもので APPROVE 判定の障害ではない。 |
LOOP_VERDICT_V2schema_version: "2" 判定根拠
|
判定: REQUEST_CHANGESPR #1206 の方向性は正しいです。Issue #1196 の中心契約である「worktree は削除済み、branch だけ残った partial cleanup を ただし、 確認した材料PR #1206 は open / draft、head SHA は 関連経緯として、Issue 側コメントでは #1147 / #1137 / #1139 / #1143 の cleanup 認可境界の反省が整理されています。特に、bare git cleanup を agent に直接許すのではなく、 PR コメント上では、初期段階に python-test regression、node-backed hook selection artifact、PR Body Japanese Check の失敗がありましたが、後続コメントでは head ブロッカーB1.
|
…B3 regression tests
|
test |
|
line1 |
LOOP_VERDICT_V2verdict: REQUEST_CHANGES |
LOOP_VERDICT_V2verdict: REQUEST_CHANGES
|
判定詳細(補足)CI 状態 HEAD 718c688 / run 28285597868
失敗根本原因Generate ci_test_selection/v1 artifact が両ジョブで exit 1。 gh pr view 1206 --json files で確認した実際の変更ファイル(3件のみ):
PR body には .github/ci/python-test-plan.json の変更が記載されているが実際には未コミット。ANCHOR_SCOPE_REFRAME_V1 で承認済みのパスだが、コミット漏れが直接の blocker。 修正方法.github/ci/python-test-plan.json の targets に tests/codex/test_cleanup_exec_branch_only.py を追加してコミットする。 Allowed Paths Gateallowed_paths_gate.status: ok(変更3ファイルは全て Allowed Paths 内。gate 違反なし。) 前回 B1/B2/B3 対応確認B1-B3 fix delta は HEAD に含まれ pytest parallel で 5342 passed。CI 失敗は B1-B3 とは無関係。 |
…an.json Merge commit 58e1f17 overwrote the PR branch's python-test-plan.json with the main version, dropping the entry for tests/codex/test_cleanup_exec_branch_only.py added in this PR. This caused CI failures in python-test and node-backed-hook-tests ("Uncovered tests: 1" / exit 1). Re-adds the entry after tests/codex/test_execpolicy_matrix.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
test connection |
LOOP_VERDICT_V2verdict: APPROVE contract_binding: allowed_paths_gate: mergeability: ci_evidence: ac_coverage: previous_blockers_resolution: schema_change_applicability: not_schema_change blockers: [] merge_ready: false iteration: 2 |
Summary
Issue #1196 の実装:
cleanup_execが worktree 削除済み・branch のみ残存する partial cleanup 状態を検出し、git branch -Dによる branch-only cleanup をstatus: okで完了できる lane を追加する。verify_cleanup_authorization()は変更なし(materialize_cleanup_contract経路を汚染しない)。branch-only verifier はrun()内でWORKTREE_NOT_IN_CATALOG時のみ発動し、条件 A-E 全満足 + PR merged + head OID match + linked issue match の場合のみgit branch -Dを実行。CLI フラグ追加なし。Checks
normal_cleanup: 4 件 PASS(通常 cleanup 経路を汚染しないことを確認)branch_only_candidate: 4 件 PASS(branch-only 候補の検出条件 A-E を検証)oid_mismatch: 2 件 PASS(head OID 不一致時の拒否を検証)path_constraint: 2 件 PASS(パス制約違反時の拒否を検証)cross_repo: 4 件 PASS(cross-repo / base-branch / linked-issue 各拒否を検証)absent_after_removal: 3 件 PASS(削除後不在確認を検証)force_delete: 5 件 PASS(強制削除フラグの動作を検証)test_local_main_branch_guard.py -k cleanup): 6 件 PASSpnpm typecheck/pnpm lint/pnpm build— ローカル環境で node_modules EACCES エラー(pre-existing)。Python-only 変更のため JS/TS に影響なし。Schema Change Applicability
スキーマファイル(
docs/schemas/)の変更なし。Python 実装の追加のみ。Schema Consumer Inventory
N/A(schema 変更なし)
Safety Claim Matrix
N/A(reason: 変更対象は
scripts/agent-ops/cleanup_exec.pyおよびtests/codex/・.github/ci/のみ。safety-sensitive パスパターンに該当なし)Notes
変更ファイル
scripts/agent-ops/cleanup_exec.py:verify_branch_only_cleanup_authorization()/_perform_branch_only()/_branch_only_result()追加、run()に branch-only lane 分岐を追加tests/codex/test_cleanup_exec_branch_only.py: 新規追加、30 テストで AC1-AC9 をカバー.github/ci/python-test-plan.json:tests/codex/test_cleanup_exec_branch_only.pyをtargetsに追加し B1/B2 CI 退行を解消既知の pre-existing 失敗
tests/context_mode/test_fetch_strict_artifact.py::test_artifact_head_sha_matches_git_headは stale artifact による pre-existing 失敗(CI では skipif)Closes #1196(Issue #1196 をクローズします)
🤖 Claude Code で自動生成されました / Generated with Claude Code