Repository navigation
Open
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasestate/queuedQueued for implementation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "post-merge-cleanup-worker のレポート信頼性向上 — git/gh 実測を source of truth とし caller premise との矛盾を flag する"
change_kind: workflowParent Issue
none(単独改善)
Parent Goal Ref
- Goal: post-merge-cleanup の cleanup レポートが git/gh の実測に基づき信頼でき、main thread による独立再検証なしで
POST_MERGE_CLEANUP_REPORT_V1を扱える状態 - Desired Destination: なし(parent なし・単独改善)
Current Validated Scope
.claude/skills/post-merge-cleanup/SKILL.mdに「実測優先」「caller premise との矛盾を warnings へ明示」「linked issue/PR state を実行時ghで取得」「worktree はgit worktree list実在のもののみ報告」のガードを追記する.claude/agents/post-merge-cleanup-worker.mdに同原則を反映する
Remaining Parent Gaps
なし
Outcome
.claude/skills/post-merge-cleanup/SKILL.md と .claude/agents/post-merge-cleanup-worker.md が更新され、post-merge-cleanup-worker が classify-git-state.py と実行時 gh クエリの実測を source of truth として扱い、caller が渡した前提(premise)と実測が矛盾する場合に POST_MERGE_CLEANUP_REPORT_V1 の warnings へ明示する手順・原則が両ファイルに記述され、全 Verification Commands が PASS している状態。
Background
2026-05-21 の PR #102 / #105 post-merge-cleanup 実行中、post-merge-cleanup-worker が以下の不正な POST_MERGE_CLEANUP_REPORT_V1 を返した:
- 自己矛盾を flag しなかった:
unresolved_cleanup_itemsにlinked_pr: 105, linked_pr_state: MERGEDと記載しながら、同じ項目の reason を「Per user instructions: Do not delete branches for PRs (feat: create_issue_txn.py の sub-issue-readback retry 共通 helper 化 + implementation Issue 標準ラベル自動付与(#79 #61) #105) that were in-progress」とし、in-progress 扱いで保持した。MERGEDと in-progress は両立しないが、矛盾をwarningsにもhuman_review_requiredにも上げなかった。 - 存在しない worktree を「存在する」と報告: 既に
git worktree listから除去済みのissue-79/issue-85worktree をworktree_path: ...付きで実在するものとして報告した。 - linked issue state の誤り: linked issue 実装: PR #81 の AC7 動作検証 (verify_acp_roundtrip.sh) を再設計し SKIP exit 0 / fallback PASS を廃止して証跡 artifact 出力と異常系シナリオを追加する #85 を
OPENと報告したが、実際は CLOSED(PR fix: redesign verify_acp_roundtrip.sh — SKIP exit 77 / fallback FAIL exit 1 / 2 scenarios / artifact log #98 で close 済み)だった。
結果として cleanup レポートが主要な事実(PR merged 状態・worktree 実在・issue state)で誤り、main thread が gh pr view / git branch -vv / git worktree list / gh issue view で全件独立再検証して cleanup をやり直した。SubAgent への委譲が機能していない。
修正方針の比較:
- 決定論的修正(採用): SKILL.md / worker.md に「実測を source of truth とし caller premise と矛盾したら warnings に明示」「state は実行時
ghで取得」「worktree はgit worktree list実在分のみ報告」を明文化する。Procedure と Guardrails に固定するため、worker のモデルに依存せず再現的に挙動が定まる。 - workaround(不採用): 呼び出し元が常に最新の前提を渡すよう運用で徹底する。caller の前提は委譲時点で陳腐化しうる(本件も委譲〜実行間に PR feat: create_issue_txn.py の sub-issue-readback retry 共通 helper 化 + implementation Issue 標準ラベル自動付与(#79 #61) #105 がマージされた)ため、運用徹底では再発を防げない。
In Scope
SKILL.mdの Guardrails / Procedure に、classify-git-state.py実測 + 実行時ghクエリを caller premise より優先する原則(マーカー語実測優先)を追記するSKILL.mdに、caller premise と実測が矛盾した場合warningsに明示し必要ならhuman_review_required: trueとする旨(マーカー語矛盾)を追記するSKILL.mdの Procedure(ステップ 3-5)に、linked issue / PR の state を実行時にgh issue view/gh pr viewで取得して判定する手順を追記するSKILL.mdの Guardrails に、git worktree listに存在する worktree のみを報告対象とする旨(固定句git worktree list に存在する worktree)を追記する.claude/agents/post-merge-cleanup-worker.mdに上記の「実測優先・矛盾 flag」原則を反映する
Out of Scope
classify-git-state.py自体の改修(実測は既に正しく返している。本件は worker の利用方法の問題)- follow-up Issue の自動起票化(運用: post-merge-cleanup と関連オーケストレーション skill で follow-up Issue を自動起票化(候補列挙 → auto-create)する #89 の範囲)
issue-refinement-loop/impl-review-loopなど他オーケストレーター skill への同種ガード横展開- post-merge-cleanup の他改善(Test Plan 検出 = 実装: post-merge-cleanup に Test Plan チェックボックス自動検出を追加する #45、inline python 集約 = 実装: post-merge-cleanup/SKILL.md 内に残存する inline python one-liner を scripts に集約 #47)
Acceptance Criteria
- AC1:
SKILL.mdに、実測(classify-git-state.py+ 実行時gh)を caller premise より優先する旨の記述があり、固定句実測優先を含む - AC2:
SKILL.mdに、caller premise と実測が矛盾した場合warningsへ明示する旨の記述があり、語矛盾を含む - AC3:
SKILL.mdの Procedure に、linked issue / PR state を実行時にgh issue viewまたはgh pr viewで取得する手順がある - AC4:
SKILL.mdの Guardrails に、git worktree list実在の worktree のみ報告する旨の記述があり、固定句git worktree list に存在する worktreeを含む - AC5:
post-merge-cleanup-worker.mdに、実測優先・矛盾 flag の原則が反映され、語実測または矛盾を含む - AC6:
pnpm typecheck/pnpm lint/pnpm test/pnpm buildが baseline から後退していない
Verification Commands
- AC1:
grep -nF "実測優先" .claude/skills/post-merge-cleanup/SKILL.md— 1 件以上ヒット(baseline 0) - AC2:
grep -nF "矛盾" .claude/skills/post-merge-cleanup/SKILL.md— 1 件以上ヒット(baseline 0) - AC3:
grep -nE "gh (issue|pr) view" .claude/skills/post-merge-cleanup/SKILL.md— 1 件以上ヒット(baseline 0) - AC4:
grep -nF "git worktree list に存在する worktree" .claude/skills/post-merge-cleanup/SKILL.md— 1 件以上ヒット(baseline 0) - AC5:
grep -nE "実測|矛盾" .claude/agents/post-merge-cleanup-worker.md— 1 件以上ヒット(baseline 0) - AC6:
pnpm typecheck && pnpm lint && pnpm test && pnpm build— いずれも exit 0
Allowed Paths
.claude/skills/post-merge-cleanup/SKILL.md.claude/agents/post-merge-cleanup-worker.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
POST_MERGE_CLEANUP_REPORT_V1スキーマ自体(フィールド追加・削除)の変更が必要になった場合
Required Skills
なし
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR。専用 worktree で作業し Draft PR を既定とする。- 同一ファイル調整:
SKILL.mdは 実装: post-merge-cleanup に Test Plan チェックボックス自動検出を追加する #45(Test Plan 検出)/ 実装: post-merge-cleanup/SKILL.md 内に残存する inline python one-liner を scripts に集約 #47(inline python 集約)/ 運用: post-merge-cleanup と関連オーケストレーション skill で follow-up Issue を自動起票化(候補列挙 → auto-create)する #89(follow-up 自動起票化)も Allowed Paths に含む。マージコンフリクト回避のため、本 Issue は他 3 件と同時並行で実装せず、いずれかが OPEN の間は直列マージ(先行 PR のマージ後に rebase)すること。
Notes for Reviewer
- 本 Issue は post-merge-cleanup workflow 実行中に検出された不具合の follow-up。観測事象の詳細は ## Background 参照。
- VC のマーカー語は baseline で 0 件であることを確認済み(
grep実測)。worktree_path単独は SKILL.md に既出(2 件)のため AC4 は固定句git worktree list に存在する worktreeで判定する。 - 関連 Issue: 実装: post-merge-cleanup に Test Plan チェックボックス自動検出を追加する #45 / 実装: post-merge-cleanup/SKILL.md 内に残存する inline python one-liner を scripts に集約 #47 / 運用: post-merge-cleanup と関連オーケストレーション skill で follow-up Issue を自動起票化(候補列挙 → auto-create)する #89(いずれも post-merge-cleanup 領域、Outcome は別物)。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasestate/queuedQueued for implementation
Activity