Skip to content

実装: post-merge-cleanup-worker が caller premise より git/gh 実測を優先し矛盾を warnings に明示する #106

Open

Description

@squne121

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: workflow

Parent 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 を返した:

  1. 自己矛盾を 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 にも上げなかった。
  2. 存在しない worktree を「存在する」と報告: 既に git worktree list から除去済みの issue-79 / issue-85 worktree を worktree_path: ... 付きで実在するものとして報告した。
  3. 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

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

Notes for Reviewer

Activity

  1. added
    state/queued
    phase/implementation
    agent/implementer
    enhancement
    on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions