Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #1528 の branch-only fallback で認可済み branch tip と削除対象 ref を同一 OID に束縛し、TOCTOU と非 ancestry error で force delete へ進まない fail-closed executor にする"
change_kind: code
dedupe_key: "follow-up:squne121/loop-protocol:pr/1528:branch-only-fallback-oid-binding:v1"
origin_skill: impl-review-loop
source_pr: "#1528"Parent Issue
なし(closed #1403 の PR #1528 review から抽出した単独 follow-up)
Parent Goal Ref
- Goal: post-merge cleanup の branch-only fallback を、認可した ref だけに限定して安全に完了できるようにする。
- Desired Destination: cleanup executor が shared mutation lock 内で expected OID を再検査し、compare-and-delete に成功した場合だけ branch-only fallback を完了する。
Current Validated Scope
scripts/agent-ops/cleanup_exec.pyの branch-only fallback は、認可で得た local branch tip と実際に削除する ref を同一 OID に束縛していない。git branch -dの任意の失敗を fallback 条件にせず、mergedness の構造的な再検査だけを force-delete への条件にする必要がある。- 既存
CLEANUP_EXEC_RESULT_V1の外部キー集合・型は変更せず、normal と fallback のverifiedpayload を同じ固定形に正規化して検証する必要がある。
Remaining Parent Gaps
- 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 の human-confirmed unpublished-commit discard lane は別の authorization / confirmation contract として扱い、本 Issue と並行実装しない。
- PR feat(cleanup): 同一実行内の branch-only fallback を追加 #1528 の最終 current-HEAD runtime evidence と PR 本文の再束縛は、実装・検証後にこの Issue の PR handoff で行う。
Background
PR #1528 の OWNER review は、authorization 後に branch ref が更新されると未認可 OID を削除し得る TOCTOU と、git branch -d の non-zero を ancestry failure と混同して -D へ進む問題を示した。決定論的修正として expected OID を destructive call まで渡し、repository mutation lock 内で compare-and-delete を使う。prompt 注記、stderr 文字列だけの分類、または bare force delete は、ref identity と failure class を保証できないため採用しない。
Outcome
更新された cleanup executor と回帰テストにより、branch-only fallback は認可済み expected OID の compare-and-delete に成功した場合だけ branch を削除し、ref 変化・invalid object・非 ancestry failure では branch を残して fail-closed result を返す状態。
In Scope
- branch-only authorization が返す expected local branch tip OID を destructive path まで保持し、shared repository mutation lock 内で ref / worktree 使用状態を再検査する。
git update-ref -d refs/heads/<branch> <expected-oid>相当の compare-and-delete に成功した場合だけ branch-only fallback を完了する。- expected OID の commit object、comparison ref、mergedness を構造的に確認し、mergedness 不成立以外の Git / ref / I/O failure では force delete に進まない。
- ref 更新 race、invalid object、non-ancestry error、same-invocation refusal を回帰テストで固定し、拒否時の partial actions と branch 残存を検証する。
- normal cleanup と branch-only fallback の
verifiedpayload を固定 key / type に正規化し、既存 result schema の外部互換性を維持する。
Out of Scope
- 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 の human-confirmed unpublished-commit discard lane、confirmation contract、replay ledger。
CLEANUP_EXEC_RESULT_V1の外部キー集合・型、公開 schema、GitHub branch protection、hook / execpolicy allowlist の変更。- remote branch delete、任意 branch の force delete、bare git command の agent 許可。
- PR feat(cleanup): 同一実行内の branch-only fallback を追加 #1528 以外の cleanup lane、repo-wide cleanup sweep、CI test plan の変更。
Acceptance Criteria
- AC1: branch-only fallback は authorization 時の expected branch tip OID を destructive path まで渡し、shared mutation lock 内の compare-and-delete が expected OID と一致した場合だけ branch を削除する。ref が更新された race では
branch_tip_changedを返し、更新後の branch を残す。 - AC2: fallback は expected OID が commit object として有効で、comparison ref に対する mergedness 不成立が構造的に確認された場合だけを扱う。invalid object、ref lock、I/O error、comparison error、その他の non-ancestry failure では force delete を実行しない。
- AC3: normal cleanup と branch-only fallback は既存
CLEANUP_EXEC_RESULT_V1の外部キー集合・型を維持し、verifiedpayload の key / type を固定して回帰テストで検証する。 - AC4: same-invocation fallback の各拒否条件では、
actions_takenは既に成功した worktree remove だけを保持し、branch は残り、force-delete subprocess は呼ばれず、既存 reason code を返す。
Runtime Verification Applicability
runtime_verification_applicability:
decision: immediate
applicable_acs: [AC1, AC2, AC3, AC4]
execution_environment: "WSL2 Ubuntu 24.04、uv locked Python、fixture Git repository"
skip_conditions: "uv、pytest、または git executable を利用できない場合は exit 77 として停止し、PASS を主張しない"
fallback_policy: "bare git delete、stderr 文字列の推測、または ref identity を検証しない成功は PASS の代替にしない"
artifact_requirements: "各 targeted pytest の command、exit code、current HEAD、refusal reason または compare-and-delete result を runtime evidence として記録する"Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_cleanup_exec.py -k test_branch_only_fallback_compare_and_delete_refuses_tip_change -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_cleanup_exec.py -k test_branch_only_fallback_refuses_invalid_object_and_non_ancestry_errors -q
# AC3
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_cleanup_exec.py -k test_branch_only_fallback_preserves_verified_payload_schema -q
# AC4
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_cleanup_exec.py -k test_same_invocation_fallback_refusals_preserve_partial_actions_and_branch -qAllowed Paths
scripts/agent-ops/cleanup_exec.pyscripts/agent-ops/tests/test_cleanup_exec.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- shared repository mutation lock と expected OID compare-and-delete を同一 destructive boundary で実現できない場合
- 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 と同じ cleanup executor path の並行変更を避ける直列化条件を確定できない場合
Required Skills
- Python
- Git ref safety
- pytest
Required Design References
docs/dev/workflow.mddocs/dev/agent-skill-boundaries.mddocs/dev/github-ops.md.claude/skills/post-merge-cleanup/SKILL.mdscripts/agent-ops/cleanup_exec.py
Scope Delta
- source: PR feat(cleanup): 同一実行内の branch-only fallback を追加 #1528 OWNER review
https://github.com/squne121/loop-protocol/pull/1528#issuecomment-5013575386 - validated_scope_delta: branch-only fallback の authorization OID と destructive delete が原子的に束縛されず、non-ancestry failure が force-delete へ誤って昇格し得る。
- deterministic_fix: expected OID を shared lock 内の compare-and-delete まで渡し、failure class を構造的に fail-closed 判定する。
- workaround_comparison: prompt 注記、stderr 文字列の分類、bare force delete は expected ref identity を保証できないため不採用。
Delivery Rule
1 Issue = 1 PRとし、専用 worktree で実装して Draft PR を作成する。- 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 が
scripts/agent-ops/cleanup_exec.pyを変更する open scope であるため、実装開始前に対象 path の先行 PR / merge 状態を readback し、同一 path の並行編集をしない。 - 最終 push 後の current HEAD に対して runtime verification と CI evidence を再生成し、PR 本文を current HEAD に再束縛してからレビューへ渡す。
Notes for Reviewer
- Source: PR feat(cleanup): 同一実行内の branch-only fallback を追加 #1528
https://github.com/squne121/loop-protocol/pull/1528#issuecomment-5013575386。 - dedupe_key:
follow-up:squne121/loop-protocol:pr/1528:branch-only-fallback-oid-binding:v1。 - Scope Collision (C1): related_issue=実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523, 実装: schema-governance.md の Initial Known Schemas を catalog から生成するスクリプト(#131 FU-5) #521, 実装: playtest-log の JSON Schema / validator の追加 #420, 実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205; overlapping_paths=scripts/agent-ops/cleanup_exec.py, scripts/agent-ops/tests/test_cleanup_exec.py.
- non_conflict_reason: 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 は merged PR の未公開 local commit を human-confirmed discard lane で扱う。実装: schema-governance.md の Initial Known Schemas を catalog から生成するスクリプト(#131 FU-5) #521/実装: playtest-log の JSON Schema / validator の追加 #420/実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205 は broad scripts / tests pattern の C1 であり、branch-only fallback の expected OID compare-and-delete と failure classification を扱わない。
- edit_intent:
cleanup_exec.pyの既存 branch-only fallback と同ファイルの回帰テストだけを変更する。confirmation contract、schema catalog、CI plan、remote delete、hook policy は変更しない。 - dependency_ordering: 実装: 明示的人間確認で未公開 commit を one-shot cleanup executor から破棄する #1523 または同一 path の open PR が実装に着手した場合は本 Issue の実装を停止し、先行 PR の merge 後に main と PR diff を readback して直列化する。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 19, 2026
Contract Review Result