Skip to content

実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141

Closed as not planned

Description

@squne121

Parent Issue

なし(単独改善。PR #2118 / Issue #2102 の follow-up)

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scripts/agent-ops/pr_head_replay_publish_exec.py::execute() を実際の production 経路から呼び出し可能にする(PR #2118 / Issue #2102 follow-up)"
change_kind: code

Parent Goal Ref

  • Goal: なし(単独 Issue)
  • Desired Destination: なし(単独 Issue)

Current Validated Scope

  • scripts/agent-ops/pr_head_replay_publish_exec.py::execute() を production 経路(impl-review-loop / open-pr / implement-issue のいずれかの publish step)から呼び出す配線を追加する
  • 呼び出し元の判定ロジック・呼び出しタイミングを既存の main drift reconciliation フローに整合させる

Remaining Parent Gaps

なし

Outcome

pr_head_replay_publish_exec.py::execute() が impl-review-loop(または open-pr / implement-issue)の publish 経路から実際に呼び出されるようになり、main drift reconciliation の replay/publish 実行ロジックが production で到達可能になっている状態。呼び出し元を明示するコード変更がマージされ、対応するユニットテストが PASS している。

In Scope

  • pr_head_replay_publish_exec.py::execute() を呼び出す production caller の実装(呼び出し元 skill/script は既存の main drift reconciliation フロー(.claude/skills/impl-review-loop の update_branch/publish step、または .claude/skills/open-pr / .claude/skills/implement-issue の publish step)から選定する)
  • caller 追加に伴う既存フロー(main drift 検知、route_loop_verdict_v2_resolve_semantic_ambiguity() 経由の compute_semantic_ambiguity() 呼び出し等)との整合確認
  • caller に対するユニットテスト追加(execute() が実際に呼ばれること、blocked/failed/success 各 status の伝播を確認するテスト)

Out of Scope

Acceptance Criteria

  • AC1: scripts/agent-ops/pr_head_replay_publish_exec.py::execute() を呼び出す production caller が repo 内に存在する
  • AC2: caller の呼び出し経路に対するユニットテストが追加され PASS している
  • AC3: 既存の scripts/agent-ops/tests/test_pr_head_replay_publish_exec.py を含む既存テストが regressed していない

Verification Commands

# AC1
# execute() を import/呼び出す非テストコードが存在することを確認(Allowed Paths 内の新規 caller ファイルがヒットする)
$ rg -n "pr_head_replay_publish_exec" --type py -g '!**/tests/**' .
# AC2
# caller の呼び出し経路に対する新規ユニットテストが PASS することを確認
$ uv run --locked pytest scripts/agent-ops/tests/test_pr_head_replay_publish_exec.py -q
# AC3
# 既存テストが regressed していないことを確認
$ uv run --locked pytest scripts/agent-ops/tests/ -k pr_head_replay_publish_exec -q

Allowed Paths

  • scripts/agent-ops/pr_head_replay_publish_exec.py
  • scripts/agent-ops/tests/test_pr_head_replay_publish_exec.py
  • .claude/skills/impl-review-loop/scripts/
  • .claude/skills/impl-review-loop/steps/
  • .claude/skills/impl-review-loop/tests/
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/open-pr/scripts/
  • .claude/skills/open-pr/SKILL.md
  • .claude/skills/implement-issue/scripts/
  • .claude/skills/implement-issue/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • docs/dev/agent-skill-boundaries.md

Scope Delta(任意)

N/A

Background

PR #2118(マージ済み、Closes #2102)は main drift 時の evidence rebind / scope-clean reconciliation を実装した。この過程で scripts/agent-ops/pr_head_replay_publish_exec.py::execute()(PR head replay/publish executor の実行部分)が main_drift_reconciliation 用の新しい安全機構(live current-base readback、git merge-tree --write-tree による deterministic conflict 判定、candidate_final_net_diff の Allowed Paths 再判定)を獲得したにもかかわらず、repo 全体で production caller が一つも存在しない(pre-existing gap、PR #2118 本文で開示済み、fresh pr-reviewer が iteration 4/5 で warning として記録)。

compute_semantic_ambiguity()(_merge_tree_conflicts() の public export)は route_loop_verdict_v2.py::route_loop_verdict_v2_resolve_semantic_ambiguity() から呼ばれるようになり初の production caller を得たが、execute() 自体(実際の publish 実行アクション)はまだ呼ばれていない。

関連: PR #2118 #2118 / Issue #2102 #2102

Source

Notes for Reviewer

Activity

  1. squne121 commented on Aug 12, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #2141
    Failure stage: label-apply
    Message: label-apply failed

    Requested:

    • labels: follow-up, pre-existing-gap, enhancement, phase/implementation, triage-required, agent/implementer
    • parent: (none)
    • blocked-by (dependencies): (none)
    • blocking: (none)
      Completed steps: create

    Failure context: command=gh issue edit --repo squne121/loop-protocol 2141 --add-label follow-up,pre-existing-gap,enhancement,phase/implementation,triage-required,agent/implementer
    output=failed to update #2141: 'pre-existing-gap' not found
    failed to update 1 issue
    matching_issue_numbers=[2141]
    issue_number=2141

    Recovery hint: stage 'label-apply' encountered an unexpected failure.
    Generic guidance: verify the issue state manually and re-run the transaction if safe.
    gh issue view 2141 --repo squne121/loop-protocol --json number,title,labels,state
    idempotent re-run: depends on the specific failure

    Please recover deterministically before re-running the create issue transaction.

  2. added
    follow-up
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 12, 2026
  3. squne121 commented on Aug 31, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。#2141 が指摘している「execute() が production から到達不能」という事実自体は正しいですが、Issue 本文のまま実装へ進めるのは勧めません。

    PR #2118 でも最終的に、compute_semantic_ambiguity() には production caller を与えた一方、pr_head_replay_publish_exec.py::execute() 本体には caller が存在しないことを明示して follow-up にしています。したがって #2141 の起票根拠は妥当です。 ただし、現在の main を見ると問題は「caller を1個足せば終わり」ではなく、そもそも replay/publish mutation を発火すべき production state transition が定義されていないことです。

    敵対的レビュー結果

    重要度 | Finding | 評価 -- | -- | -- BLOCKER | execute() に渡す authority の producer が定義されていない | execute() は source_base, source_head, expected_remote_pr_head に加えて main-drift 時は current_base_branch, expected_current_base_sha を必要とします。ところが現在の route_scope_clean_reconciliation action は evidence epoch / reusable evidence / rerun flags しか返さず、これら replay 用 SHA の provenance がありません。 current main のコード検索でも source_base / expected_remote_pr_head は executor とテスト群にしか現れていません。 BLOCKER | AC1 が現状のまま false-green | AC1 の rg -n "pr_head_replay_publish_exec" --type py -g '!**/tests/**' . は、すでに route_loop_verdict_v2.py が compute_semantic_ambiguity() を import しているため、execute() が一度も呼ばれなくてもヒットします。Issue が求める「execute の production caller」の証明になっていません。Issue 本文自身は AC1 を caller 存在証明として扱っています。 BLOCKER | AC2 も caller を検証していない | 指定されている test_pr_head_replay_publish_exec.py は executor 本体の offline test であり、現在でも caller がゼロの状態で PASS します。既存テストは成功、stale head、Allowed Paths、race 等を executor に直接入力しているだけです。 main-drift integration test も同様に execute() を直接呼んでいます。 HIGH | Issue の status contract が実装と違う | Issue は「blocked/failed/success 各 status の伝播」としていますが、現実の success status は ok です。 小さく見えますが、caller adapter を作る Issue でこれは契約バグです。 HIGH | main-drift safety を誤って無効化できる | main_drift_reconciliation = bool(current_base_branch and expected_current_base_sha) なので、caller が片方を渡し忘れると blocked ではなく、通常 replay path に静かに downgrade します。 #2141 は execute() 自体を Out of Scope にしているため、単に caller を作るだけだとこの footgun が production に露出します。 HIGH | Git エラーを「semantic conflict」と誤分類する | _merge_tree_conflicts() は returncode != 0 をすべて conflict としています。 しかし Git 公式仕様では git merge-tree --write-tree は 0=clean、1=conflict、それ以外=処理自体の失敗です。つまり missing object、Git failure 等まで「semantic ambiguity」として workflow を止めます。これはセキュリティより、個人開発で邪魔になる reliability 問題です。(Git) HIGH | subprocess timeout が status に変換されない | デフォルト runner は timeout=60 を設定していますが TimeoutExpired / OSError を捕捉していません。 production caller を付けると、「blocked/failed を返す executor」という期待に反して例外で orchestration 自体が落ちる経路が増えます。 HIGH | open-pr は caller 候補として不適切 | 現行 open_pr.py の publish は branch publish ではなく、body validation 後の gh pr create です。 一方 execute() は既存 pr_number と PR head を必要とします。PR 作成前には呼べず、作成直後に呼ぶなら「PR を作ってから branch を replay して head を変える」という不自然な lifecycle になります。#2141 の候補から open-pr は外すべきです。 HIGH | BEHIND 経路にはすでに適切な canonical executor がある | 現行 Step 5 は BEHIND に対し implement-issue.update_branch を合成し、GitHub Update Branch API を使います。 update_branch.py は expected_head_sha を CAS input にしています。 GitHub 公式 API 自体も base の最新 HEAD を PR head に merge し、expected_head_sha 不一致を拒否し、成功要求を 202 Accepted として扱います。(GitHub Docs) ここを replay executor へ置換する理由はありません。 MEDIUM | scope-clean reconciliation と replay mutation が混同されている | 現行 route_scope_clean_reconciliation は snapshot / CI / review の stale evidence を再取得し、evidence epoch を current main に rebind して Step 5 を再実行する経路です。branch head を変更する処理ではありません。 ここに execute() を直結すると #2102 で確立した state semantics 自体が変わります。 MEDIUM | Allowed Paths が caller 選定前から広すぎる | impl-review-loop / open-pr / implement-issue の各 directory を丸ごと許可してから caller を選ぶ構造で、実際に issue 本文でも overlap ノイズが発生しています。 caller を決めてから exact file に narrow する方が実装もレビューも軽くなります。

    外部仕様と照合した評価

    push 周りをさらにハードニングする必要性は低いです。現在の executor は --force-with-lease=<ref>:<expect> の exact form を使っており、Git 公式仕様でもこの形式は remote ref が指定した expected value と一致する場合だけ更新するものです。ここは妥当です。(Git)

    したがって、個人趣味開発という前提では 新しい guard / approval / security artifact を追加する方向には進めない方がよいです。問題はセキュリティ不足ではなく、mutation path が二重化し、入力 authority が曖昧なことです。GitHub の mergeStateStatus も BEHIND / DIRTY / CLEAN 等を区別しており、現在の「BEHIND は update-branch、actual conflict は別処理」という分離は自然です。(GitHub Docs)

    推奨アクション

    1. 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 をいったん implementation-ready 扱いしない。 最初に「どの production state が replay/publish を本当に必要とするか」を確定します。現状の canonical flow だけを見ると、BEHIND は update_branch、非-BEHIND main drift は evidence rebind、通常 branch publish は既存 publish lane で処理されており、source_base..source_head を別 commit として PR head に replay する必須状態が見つかりません。

    2. その状態が存在しないなら、実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 は not planned が第一候補です。 execute() は dead/legacy executor として削除候補にし、今 production 利用されている compute_semantic_ambiguity() は小さな Git helper module へ分離するのが長期的には分かりやすいです。PR fix(loop): main drift evidence を再束縛する (#2102) #2118 のレビュー自身も、「caller 不在なら本当に AC に必要なのか、それとも optional/defense-in-depth なのかを判断せよ」と明示していました。

    3. 本当に replay が必要なら、caller は impl-review-loop の専用 action に限定します。 open-pr には入れず、既存 update_branch も置換しません。例えば明示的な route_replay_publish / replay_publish action を設け、その action の producer が source_base, source_head, expected_remote_pr_head, current_base_sha を「同一 decision cycle の authority」として生成する設計にします。ただしこれは現行 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 が想定する「import/呼び出しを追加するだけ」より明確に大きい変更です。

    4. VC を先に修正します。 AC1 は generic rg ではなく、選定した production adapter が execute() を呼ぶことを静的または AST test で確認する。AC2 は「replay action → execute が exactly once」「その他 route → execute 0 回」「main drift では2つの current-base 引数が必ず揃う」「ok → verification + PR review 再実行」「CAS/drift blocked → fresh readback / reroute」を caller-level test にします。

    5. production wiring 前に executor の2つの小さな reliability defect を直します。 merge-tree の exit 1 だけを conflict とし、それ以外は execution failure に分離すること、TimeoutExpired / OSError を failed に変換することです。また current_base_branch と expected_current_base_sha は XOR を invalid_arguments にすべきです。この3点は guard 強化ではなく、不要な停止・クラッシュを減らす変更です。

    最終評価

    #2141 の problem statement は正しいです。「死んだ production path がある」という観測は PR #2118 のレビューとも一致します。

    しかし solution statement はまだ不十分です。現状のまま進めると、AC が green になっても execute() の main-drift reconciliation が実際には使われない、あるいは既存 update_branch / publish lane と競合する実装ができる可能性があります。

    私なら現段階では 「実装する」より先に #2141 を reframe します。優先順位は 「replay mutation が本当に必要な状態を証明 → なければ not planned、あれば impl-review-loop に単一の明示 action として配線」 です。セキュリティ機構を増やす必要はありません。むしろ今は mutation path を減らす方が、品質・有用性・日常のワークフローすべてに効きます。

    ## 判定

    REQUEST_CHANGES。#2141 が指摘している「execute() が production から到達不能」という事実自体は正しいですが、Issue 本文のまま実装へ進めるのは勧めません。

    PR #2118 でも最終的に、compute_semantic_ambiguity() には production caller を与えた一方、pr_head_replay_publish_exec.py::execute() 本体には caller が存在しないことを明示して follow-up にしています。したがって #2141 の起票根拠は妥当です。 ただし、現在の main を見ると問題は「caller を1個足せば終わり」ではなく、そもそも replay/publish mutation を発火すべき production state transition が定義されていないことです。

    敵対的レビュー結果

    重要度 Finding 評価
    BLOCKER execute() に渡す authority の producer が定義されていない execute() は source_base, source_head, expected_remote_pr_head に加えて main-drift 時は current_base_branch, expected_current_base_sha を必要とします。ところが現在の route_scope_clean_reconciliation action は evidence epoch / reusable evidence / rerun flags しか返さず、これら replay 用 SHA の provenance がありません。 current main のコード検索でも source_base / expected_remote_pr_head は executor とテスト群にしか現れていません。
    BLOCKER AC1 が現状のまま false-green AC1 の rg -n "pr_head_replay_publish_exec" --type py -g '!**/tests/**' . は、すでに route_loop_verdict_v2.py が compute_semantic_ambiguity() を import しているため、execute() が一度も呼ばれなくてもヒットします。Issue が求める「execute の production caller」の証明になっていません。Issue 本文自身は AC1 を caller 存在証明として扱っています。
    BLOCKER AC2 も caller を検証していない 指定されている test_pr_head_replay_publish_exec.py は executor 本体の offline test であり、現在でも caller がゼロの状態で PASS します。既存テストは成功、stale head、Allowed Paths、race 等を executor に直接入力しているだけです。 main-drift integration test も同様に execute() を直接呼んでいます。
    HIGH Issue の status contract が実装と違う Issue は「blocked/failed/success 各 status の伝播」としていますが、現実の success status は ok です。 小さく見えますが、caller adapter を作る Issue でこれは契約バグです。
    HIGH main-drift safety を誤って無効化できる main_drift_reconciliation = bool(current_base_branch and expected_current_base_sha) なので、caller が片方を渡し忘れると blocked ではなく、通常 replay path に静かに downgrade します。 #2141 は execute() 自体を Out of Scope にしているため、単に caller を作るだけだとこの footgun が production に露出します。
    HIGH Git エラーを「semantic conflict」と誤分類する _merge_tree_conflicts() は returncode != 0 をすべて conflict としています。 しかし Git 公式仕様では git merge-tree --write-tree は 0=clean、1=conflict、それ以外=処理自体の失敗です。つまり missing object、Git failure 等まで「semantic ambiguity」として workflow を止めます。これはセキュリティより、個人開発で邪魔になる reliability 問題です。(Git)
    HIGH subprocess timeout が status に変換されない デフォルト runner は timeout=60 を設定していますが TimeoutExpired / OSError を捕捉していません。 production caller を付けると、「blocked/failed を返す executor」という期待に反して例外で orchestration 自体が落ちる経路が増えます。
    HIGH open-pr は caller 候補として不適切 現行 open_pr.py の publish は branch publish ではなく、body validation 後の gh pr create です。 一方 execute() は既存 pr_number と PR head を必要とします。PR 作成前には呼べず、作成直後に呼ぶなら「PR を作ってから branch を replay して head を変える」という不自然な lifecycle になります。#2141 の候補から open-pr は外すべきです。
    HIGH BEHIND 経路にはすでに適切な canonical executor がある 現行 Step 5 は BEHIND に対し implement-issue.update_branch を合成し、GitHub Update Branch API を使います。 update_branch.py は expected_head_sha を CAS input にしています。 GitHub 公式 API 自体も base の最新 HEAD を PR head に merge し、expected_head_sha 不一致を拒否し、成功要求を 202 Accepted として扱います。([GitHub Docs]2) ここを replay executor へ置換する理由はありません。
    MEDIUM scope-clean reconciliation と replay mutation が混同されている 現行 route_scope_clean_reconciliation は snapshot / CI / review の stale evidence を再取得し、evidence epoch を current main に rebind して Step 5 を再実行する経路です。branch head を変更する処理ではありません。 ここに execute() を直結すると #2102 で確立した state semantics 自体が変わります。
    MEDIUM Allowed Paths が caller 選定前から広すぎる impl-review-loop / open-pr / implement-issue の各 directory を丸ごと許可してから caller を選ぶ構造で、実際に issue 本文でも overlap ノイズが発生しています。 caller を決めてから exact file に narrow する方が実装もレビューも軽くなります。

    外部仕様と照合した評価

    push 周りをさらにハードニングする必要性は低いです。現在の executor は --force-with-lease=<ref>:<expect> の exact form を使っており、Git 公式仕様でもこの形式は remote ref が指定した expected value と一致する場合だけ更新するものです。ここは妥当です。(Git)

    したがって、個人趣味開発という前提では 新しい guard / approval / security artifact を追加する方向には進めない方がよいです。問題はセキュリティ不足ではなく、mutation path が二重化し、入力 authority が曖昧なことです。GitHub の mergeStateStatus も BEHIND / DIRTY / CLEAN 等を区別しており、現在の「BEHIND は update-branch、actual conflict は別処理」という分離は自然です。([GitHub Docs]4)

    推奨アクション

    1. 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 をいったん implementation-ready 扱いしない。 最初に「どの production state が replay/publish を本当に必要とするか」を確定します。現状の canonical flow だけを見ると、BEHIND は update_branch、非-BEHIND main drift は evidence rebind、通常 branch publish は既存 publish lane で処理されており、source_base..source_head を別 commit として PR head に replay する必須状態が見つかりません。

    2. その状態が存在しないなら、実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 は not planned が第一候補です。 execute() は dead/legacy executor として削除候補にし、今 production 利用されている compute_semantic_ambiguity() は小さな Git helper module へ分離するのが長期的には分かりやすいです。PR fix(loop): main drift evidence を再束縛する (#2102) #2118 のレビュー自身も、「caller 不在なら本当に AC に必要なのか、それとも optional/defense-in-depth なのかを判断せよ」と明示していました。

    3. 本当に replay が必要なら、caller は impl-review-loop の専用 action に限定します。 open-pr には入れず、既存 update_branch も置換しません。例えば明示的な route_replay_publish / replay_publish action を設け、その action の producer が source_base, source_head, expected_remote_pr_head, current_base_sha を「同一 decision cycle の authority」として生成する設計にします。ただしこれは現行 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 が想定する「import/呼び出しを追加するだけ」より明確に大きい変更です。

    4. VC を先に修正します。 AC1 は generic rg ではなく、選定した production adapter が execute() を呼ぶことを静的または AST test で確認する。AC2 は「replay action → execute が exactly once」「その他 route → execute 0 回」「main drift では2つの current-base 引数が必ず揃う」「ok → verification + PR review 再実行」「CAS/drift blocked → fresh readback / reroute」を caller-level test にします。

    5. production wiring 前に executor の2つの小さな reliability defect を直します。 merge-tree の exit 1 だけを conflict とし、それ以外は execution failure に分離すること、TimeoutExpired / OSError を failed に変換することです。また current_base_branch と expected_current_base_sha は XOR を invalid_arguments にすべきです。この3点は guard 強化ではなく、不要な停止・クラッシュを減らす変更です。

    最終評価

    #2141 の problem statement は正しいです。「死んだ production path がある」という観測は PR #2118 のレビューとも一致します。

    しかし solution statement はまだ不十分です。現状のまま進めると、AC が green になっても execute() の main-drift reconciliation が実際には使われない、あるいは既存 update_branch / publish lane と競合する実装ができる可能性があります。

    私なら現段階では 「実装する」より先に #2141 を reframe します。優先順位は 「replay mutation が本当に必要な状態を証明 → なければ not planned、あれば impl-review-loop に単一の明示 action として配線」 です。セキュリティ機構を増やす必要はありません。むしろ今は mutation path を減らす方が、品質・有用性・日常のワークフローすべてに効きます。

  4. squne121 commented on Aug 31, 2026

    @squne121
    OwnerAuthor

    確認した範囲では、今回は #2141 の実装を進めるのではなく、アンカーコメントを human context として issue-refinement-loop に取り込み、Issue 自体を reframe するのが適切です。アンカーは「replay mutation が必要な production state をまず証明し、存在しなければ not planned、存在するなら impl-review-loop の単一 action として設計」としています。

    また現行 issue-refinement-loop は loop iteration ごとの承認を既定で要求せず、Step 1 の codebase-investigator、必要時の web-researcher を使う構造です。canonical Step 2 では旧 issue-reviewer SubAgent を直接起動せず root-owned pipeline を使うため、そこも明示してあります。

    技術面でも、Git は merge-tree --write-tree の exit 0/1/その他を clean/conflict/error と区別し、GitHub Update Branch API は expected_head_sha 不一致を拒否するため、アンカーの reliability / CAS に関する問題提起は妥当です。 ([Git]1)

    そのまま Claude-GPT に渡せる形です。

    #2141 (comment)

    を operator-selected human context の anchor comment として扱い、Issue #2141 に対して issue-refinement-loop を実行してください。

    目的は Issue #2141 をそのまま実装することではありません。
    この anchor comment の REQUEST_CHANGES を current main の repository evidence と照合し、Issue の problem statement / solution statement / Acceptance Criteria / Verification Commands / Allowed Paths / Outcome を再評価し、実装に進める前に Issue 契約を正しい状態へ refinement することです。

    実行方針

    • この依頼では issue-refinement-loop の各 iteration の人間承認は不要です。
    • needs-fix が返った場合、current skill の max_iterations / loop policy の範囲内で自動継続してください。
    • iteration ごとに「続けてよいですか」「Issue を更新してよいですか」等の確認を私に求めないでください。
    • ただし、Claude Code / Claude-GPT 自体の permission mode、bypassPermissions、--dangerously-skip-permissions 等を変更する意味ではありません。現在与えられている実行権限の範囲で進めてください。
    • canonical policy が最終的に human_judgment_required / human_escalation を要求する場合だけ、その理由と unresolved blockers を明示して停止してください。単なる慎重論を理由に人間判断へ逃がさないでください。
    • max_iterations 到達までは、policy が自動継続を許す限り自動で修正・再レビューしてください。

    Anchor comment の扱い

    この URL は今回、私が明示的に選択した human context です。

    したがって、current issue-refinement-loop / command_registry.py / skill runtime policy を読み、現在の canonical human-context profile を使用してください。

    • URL だけから origin を推測しないこと。
    • unlabeled anchor lane や agent-report lane に落とさないこと。
    • current skill が preflight.run.with_human_context 等の profile を定義している場合、それを canonical executor 経由で使用すること。
    • このプロンプトに古いコマンド列をコピーして実行するのではなく、current main の SKILL.md / command registry を SSOT として exact invocation を導出してください。
    • raw anchor body を planner / rewrite input に無制限に流さず、current anchor-comment handling contract に従って normalized feedback / authority evidence として扱ってください。

    最初に行うこと

    canonical main root / default branch の状態を確認し、必要なら安全に同期してください。

    その後、current main の以下を必ず読んでください。

    過去の記憶や古い worktree の内容ではなく、current main を根拠にしてください。

    Preflight

    Step 0 / Step 0f を current canonical entrypoint から実行してください。

    この anchor は human context なので、human-context lane を明示してください。

    preflight / planner の出力を prose で勝手に再判定せず、

    • STATUS
    • NEXT_ACTION
    • MUST_READ
    • COMMANDS_JSON
    • BLOCKERS
    • ARTIFACT
    • current planner result

    をそのまま consumer contract に従って処理してください。

    trusted contract patch plan / deterministic contract-update route が生成された場合は、current skill が許可する parent-owned canonical transaction を使用して構いません。

    サブエージェントの使用

    サブエージェントを必ず使用してください。

    少なくとも Step 1 の investigation が planner により required なら、codebase-investigator を起動してください。

    調査対象には以下を含めてください。

    1. pr_head_replay_publish_exec.py::execute() の current implementation
    2. production caller の有無
    3. source_base
    4. source_head
    5. expected_remote_pr_head
    6. current_base_branch
    7. expected_current_base_sha
    8. それら authority value の producer / provenance
    9. route_scope_clean_reconciliation
    10. route_loop_verdict_v2
    11. impl-review-loop の current Step 5 / publish / update-branch routing
    12. implement-issue の update_branch
    13. open-pr の lifecycle
    14. pr_head_replay_publish_exec 関連 tests
    15. PR fix(loop): main drift evidence を再束縛する (#2102) #2118 でこの executor が作られた経緯と最終 review disposition

    codebase-investigator は read-only とし、Issue / repository を mutation させないでください。

    planner が Web research を required とした場合は web-researcher も使用してください。

    両方 required なら並列起動して構いませんが、両サブエージェントの作業完了を必ず待ってください。

    重要:

    • 「バックグラウンドで実行中です」で main task を終了しないこと。
    • pending の SubAgent が存在する状態で Step 2 へ進まないこと。
    • SubAgent の完了通知 / structured result を実際に受け取るまで待つこと。
    • 複数 SubAgent を起動した場合は全員を join してから review に進むこと。
    • issue-editor 等の mutation worker を後から起動した場合も、同様に完了を待ち、readback まで行うこと。
    • parent orchestrator が delegation owner です。SubAgent 自身に不要な nested SubAgent delegation をさせないでください。
    • Issue 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 本文にある「nested SubAgent delegation が必要なら stop」は implementation scope の stop condition であり、issue-refinement-loop 自身が規定している top-level investigation / web research worker を禁止するものとして誤解しないでください。

    Web research

    external claims が decision-dispositive なら、一次資料を優先してください。

    特に必要なら以下を確認してください。

    • Git git merge-tree --write-tree

      • clean / conflict / execution error の exit status
    • Git push --force-with-lease=<ref>:<expect>

    • GitHub REST API Update a pull request branch

      • expected_head_sha
      • stale SHA 時の挙動
      • response semantics
    • GitHub GraphQL mergeStateStatus

      • BEHIND / DIRTY / CLEAN 等

    ブログや二次解説より公式 Git / GitHub documentation を優先してください。

    ただし、Web research のために新しい security framework / approval layer を提案しないでください。
    この repository は個人趣味開発です。品質・有用性・日常運用の単純さを優先し、guard / harness / security artifact を増やすこと自体を目的化しないでください。

    Anchor comment の主要 Finding を fact-check すること

    以下を「正しい前提」として盲目的に採用せず、current main に対して fact-check してください。

    A. replay/publish mutation を要求する production state が存在するか

    最重要です。

    現在の canonical flow を列挙し、

    • BEHIND
    • main drift / evidence stale
    • actual merge conflict
    • 通常 publish
    • PR creation
    • review 後 rerun

    などの state ごとに、現在どの action / executor が担当しているかを確認してください。

    そのうえで、

    source_base..source_head を別 commit として PR head に replay/publish しなければならない production state

    が本当に存在するかを証明してください。

    「executor が存在するから caller が必要」という circular reasoningは禁止です。

    B. authority producer

    execute() が要求する各 SHA / branch input が、

    • どこで取得されるか
    • 同一 decision cycle の snapshot に束縛されるか
    • stale value と current value を混在させないか
    • caller に渡す canonical producer が既に存在するか

    を確認してください。

    producer が存在しないなら「caller を足せばよい」と結論しないでください。

    C. AC1 false-green

    現行 Issue の AC1 / Verification Command が、

    execute() の production caller がゼロでも PASS し得るか

    を確認してください。

    pr_head_replay_publish_exec module の別 symbol、特に compute_semantic_ambiguity() の import だけで generic rg がヒットするなら、AC1 は caller existence verification になっていません。

    D. AC2 false-green

    test_pr_head_replay_publish_exec.py 等が executor を直接テストしているだけで、production caller / route を通していないなら、それを明示してください。

    E. status contract

    Issue が success と書いている場合、current implementation の success status が本当に success なのか ok なのか確認してください。

    F. main-drift argument pair

    current_base_branch と expected_current_base_sha の片方だけを caller が渡した場合の挙動を確認してください。

    silent downgrade が存在するなら production wiring 前に reliability defect として扱うべきか評価してください。

    G. merge-tree error classification

    git merge-tree --write-tree の

    • 0
    • 1
    • その他

    が executor 内で正しく区別されているか確認してください。

    H. subprocess failures

    TimeoutExpired / OSError 等が structured failed result に変換されるのか、例外として orchestration を落とすのか確認してください。

    I. open-pr

    PR 作成前/後 lifecycle と execute() の required inputs を比較し、open-pr が caller 候補として自然か確認してください。

    J. BEHIND

    current impl-review-loop が BEHIND に対して既に implement-issue.update_branch / GitHub Update Branch API 等を使っているなら、それを replay executor に置換する合理的理由があるか確認してください。

    K. scope-clean reconciliation

    evidence rebind / snapshot refresh と branch mutation を混同していないか確認してください。

    推奨 disposition

    以下を hypothesis / decision tree として扱ってください。結論を先に固定しないでください。

    第一候補

    調査の結果、replay/publish mutation を必要とする固有の production state が存在しないなら、

    #2141 を「production caller を追加する implementation Issue」として維持しない

    方向を第一候補にしてください。

    その場合は current issue-refinement-loop の classification / termination policy に従い、

    • reframe_in_place
    • superseded_by_decision
    • not planned

    のどれが canonical かを決定してください。

    anchor comment は「not planned を第一候補」としていますが、「必ず今すぐ close せよ」という命令として雑に解釈しないでください。

    canonical policy 上、close / not planned が十分に authority-backed で deterministic なら、追加承認を求めず実行して構いません。

    一方で close authority が不足しているが Issue 契約の再構成は可能なら、無理に close せず reframe_in_place を完了してください。

    replay が本当に必要だった場合

    production state が concrete に存在すると repository evidence で証明できた場合のみ、Issue を implementation-ready に再構成してください。

    その場合:

    • caller は原則 impl-review-loop の明示的な専用 action として設計する
    • open-pr に押し込まない
    • 既存 BEHIND update_branch lane を理由なく置換しない
    • scope-clean evidence rebind と branch mutation を混同しない
    • replay action の authority producer を明示する
    • caller 選定後に Allowed Paths を exact file 単位へ narrow する
    • broad directory allowlist を惰性で維持しない

    ことを重視してください。

    Acceptance Criteria / Verification Commands の修正

    Issue を実装可能な形で残す場合、少なくとも以下の性質を検証できる VC にしてください。

    • 選定された production route から execute() が exactly once 呼ばれる
    • replay 対象でない route では 0 回
    • required authority inputs が同一 decision cycle から生成される
    • current-base pair が片方だけ欠ける状態を許さない
    • success contract は current implementation と一致
    • blocked / failed が caller / orchestrator に正しく伝播
    • stale CAS / drift 時は fresh readback / reroute される
    • generic module import の存在だけでは AC1 が PASS しない
    • executor direct unit test だけでは AC2 が PASS しない

    可能なら caller-level integration/unit test を VC にしてください。

    reliability defect の扱い

    anchor comment が挙げている以下は、production wiring 前の小さな reliability prerequisite 候補として評価してください。

    • merge-tree exit 1 のみ conflict、その他 nonzero は execution failure
    • TimeoutExpired / OSError を structured failure に変換
    • current_base_branch XOR expected_current_base_sha を invalid arguments とする

    ただし、Issue #2141 の scope に機械的に全部追加しないでください。

    replay executor を production 化しない disposition なら、その dead path の hardening 自体が不要になる可能性があります。

    必要性・scope ownership・dedupe を確認し、current refinement policy に従ってください。

    新規 Issue 作成が必要になった場合も、勝手に issue proliferation しないでください。current follow-up materialization / dedupe / scope policy が deterministic に許可する場合だけ行ってください。

    Rewrite / Issue mutation

    review 結果が needs-fix で canonical route が rewrite を要求した場合は、current skill が指定する issue-author / issue-editor 等の mutation worker を使用してください。

    以下を許可します。

    • Issue 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 本文の更新
    • title の更新(reframe に必要な場合)
    • Acceptance Criteria / Verification Commands / Outcome / Scope / Allowed Paths / Stop Conditions の修正
    • stale presentation-only labels の hygiene
    • current loop policy が要求する refinement/result comment の投稿
    • canonical close / not-planned transitionが deterministic に許可された場合の Issue state 更新
    • refinement loop が必要とする artifact / scratch / tests の生成
    • read-only repository investigation
    • current skill が要求する deterministic checker / contract readiness / tests の実行

    これらについて逐一私の承認を求める必要はありません。

    ただし、この依頼は Issue refinement です。

    以下はこの実行では行わないでください。

    • pr_head_replay_publish_exec.py の production code 実装
    • caller の実装
    • executor reliability fix の実装
    • impl-review-loop による implementation
    • PR 作成
    • unrelated repository refactor

    Issue が最終的に implementation_ready になった場合でも、そこで refinement task を完了してください。実装フェーズへ自動的に進まないでください。

    Review

    current issue-refinement-loop の canonical Step 2 をそのまま使用してください。

    legacy な issue-reviewer SubAgent を canonical Step 2 として独自に復活させないでください。

    current main が run_root_review_pipeline.py root-owned producer を canonical としているなら、その結果を直接 consume してください。

    status / verdict / next_action の組を prose で再判定しないでください。

    needs-fix なら iteration budget 内で rewrite → fresh review を自動継続してください。

    Issue body を変更した後は stale review / stale contract result を再利用せず、fresh readback と必要な fresh review/readiness を実行してください。

    終了条件

    次のいずれかになるまで続けてください。

    1. Issue が refinement policy 上 approved / implementation-ready になった
    2. canonical decision により 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 が not planned / superseded 等として完了した
    3. max iterations に到達して canonical human_escalation
    4. deterministic に解消不能な human_judgment_required
    5. environment failure で実行継続不能

    1 または 2 の場合は、人間の追加承認を待たずに refinement loop を完了してください。

    3〜5 の場合だけ停止してください。

    最終報告

    最後に以下を簡潔に報告してください。

    • termination reason
    • Issue 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 の最終 state
    • anchor comment の final classification
    • replay/publish mutation を必要とする production state が存在したか
    • 採用した disposition とその evidence
    • Issue body をどう変更したか
    • AC / VC / Allowed Paths の主要変更
    • 実行した deterministic checks / tests と結果
    • 使用した SubAgent とその結果
    • Web research を行った場合の一次資料
    • unresolved blockers
    • follow-up が materialize された場合はその URL
    • implementation-ready の場合は「実装はまだ開始していない」こと

    SubAgent の作業が残った状態では最終報告を出さないでください。
    すべての起動済み SubAgent の完了を待ち、結果を join し、必要な GitHub readback を完了してから終了してください。

    特に今回は、**「not planned を強制」ではなく「not planned を強い第一仮説として fact-check → canonical classification に従う」**形にしています。これならアンカーコメントの意図を保ちつつ、issue-refinement-loop 自身の authority/routing を迂回しません。

  5. squne121 commented on Aug 31, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    • Issue: 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141
    • Termination cause: environment_failure
    • Control-plane blocker: structural_repair_action.apply returned phase: complete, mutation_outcome: not_attempted, failure_code: transaction_execute_error; no Issue mutation was attempted.
    • Required deterministic repair: add the template-derived ## Runtime Verification Applicability section. The controlled transaction failed before mutation, so the canonical policy forbids retrying it blindly or falling through to a manual rewrite/review route.
    • Anchor context: operator_asserted_human_context. Fact-check completed read-only; the selected anchor remains unclassified because the required contract repair did not complete.
    • Investigation result: no current production state was found that demonstrably requires source-range replay/publish mutation; existing lanes handle BEHIND (update_branch), scope-clean evidence reconciliation, ordinary publish, and PR creation. This observation was not applied to the Issue because the control-plane repair failure blocks the required fresh preflight/review cycle.
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  6. squne121 commented on Sep 2, 2026

    @squne121
    OwnerAuthor

    結論

    Verdict: REQUEST_CHANGES。Issue #2141 は現状の契約のまま実装へ進めるべきではありません。

    再検証した結果、既存の敵対的レビューで指摘された中心問題は、2026-09-02 時点の main でも解消されていません。特に重要なのは、execute() が死んでいることそのものではなく、「どの production state が、この executor による source-range replay/publish を必要とするのか」が未定義なことです。PR #2118 自身も compute_semantic_ambiguity() には production caller を与えた一方、execute() 本体の caller は follow-up gap として残しています。

    さらに今は #2141 の広い Allowed Paths が、無関係に近い Issue #2467 を「#2141 merge 後まで開始しない」という依存状態にしています。個人開発でワークフロー効率を優先するなら、これは放置コストが実装メリットを上回り始めています。

    敵対的レビュー結果

    Severity | Finding | 評価 -- | -- | -- P0 | production caller 以前に input authority producer が存在しない | 現行コード検索では expected_remote_pr_head は executor 本体とテストにしか存在しません。source-base の CLI input も executor にしかありません。つまり source_base / source_head / expected_remote_pr_head を「同じ decision cycle の正本」として生成する production component がありません。caller を1行足すだけでは成立しません。 P0 | execute() は Update Branch の代替ではない | executor は既存 PR head から detached worktree を作り、source_base..source_head の net diff を git apply して新しい1コミットを追加し、それを lease 付き push します。current base は conflict/final-diff 検査に使うだけで、PR head を current main 上へ作り直す処理ではありません。 P0 | BEHIND には既に canonical executor がある | 現行 router は merge_state_status == BEHIND を明示的に implement-issue.update_branch へ route し、verification / PR review を再実行します。GitHub の公式 Update Branch API も base HEAD を PR branch へ merge するための API で、expected_head_sha 不一致は 422 で拒否します。こちらが BEHIND に対する自然な実装です。 (GitHub Docs) P0 | AC1 / AC2 が false-green | Issue の AC1 は generic rg "pr_head_replay_publish_exec" ですが、現行 production code はすでに同 module の compute_semantic_ambiguity() を import しています。したがって execute() を誰も呼ばなくても AC1 が green になります。AC2 も executor 自身の既存テストを実行するだけで caller 配線を証明しません。 P1 | production 化するには executor 自体の reliability 修正が必要なのに Out of Scope | _merge_tree_conflicts() は returncode != 0 を全部 conflict としています。しかし Git 公式仕様では 0=clean, 1=conflict, それ以外=実行エラーです。現状では Git 自体のエラーが意味上の conflict に化けます。 (Git) P1 | subprocess failure が workflow failure ではなく Python crash になり得る | replay executor の _run() は timeout=60 を設定する一方、TimeoutExpired / OSError を捕捉しません。対して既存 update_branch.py はこの2つを明示的に正規化しています。自動 caller を付ける前に揃えるべきです。 P1 | partial main-drift args が fail-closed せず通常モードへ downgrade | main_drift_reconciliation = bool(current_base_branch and expected_current_base_sha) なので片方だけ渡すと invalid_arguments ではなく reconciliation 無効として処理が進みます。production caller の typo が安全機構を静かに無効化します。 P1 | worktree cleanup failure が完全に捨てられる | git worktree remove --force が失敗しても cleanup_error は return result へ載らず、最後に _ = cleanup_error, pushed で捨てられます。頻繁に自動実行するなら .claude/worktrees/ の残骸が運用ノイズになります。セキュリティより実用上の friction として直す価値があります。 P1 | open-pr は lifecycle 上 caller 候補にならない | open_pr.py は検証後に gh pr create する PR 作成 wrapper です。一方 replay executor は既存の pr_number, headRefOid, target branch を最初から必要とします。PR 作成前には呼べず、作成直後なら「PRを作ってからそのheadを書き換える」という不自然な順序になります。 P1 | 広すぎる Allowed Paths が実際に他 Issue を止めている | #2467 は #2141 が .claude/skills/impl-review-loop subtree を広く持っているため、明示的に「#2141 merge 後に開始」としています。まだ caller file すら選定できていない Issue が、別の具体的改善の hard predecessor になっています。これはハーネス由来の実害です。 P2 | executor 自体には operator utility はありそう | PR #2070 の conflicting branch recovery では control-plane が exact-old lease と live readback を手動再現して reconciliation しています。したがって「機能自体が完全に無価値」とまでは言えません。ただしこれは 自動 Step 5 action より explicit recovery/operator tool のユースケースを支持する証拠です。

    外部仕様との照合

    現在の replay publisher が使う exact form の --force-with-lease=<ref>:<expect> は、remote ref が指定した <expect> と一致するときだけ update を許可する Git の正式な CAS 機構です。ここへさらに独自 locking・approval artifact・persistent ledger を追加する必要性は低いです。むしろ現在の exact lease を維持したまま mutation path を減らす方が、個人開発では合理的です。 (Git)

    また GitHub 自身が BEHIND を「head ref is out of date」、DIRTY を「merge commit cannot be cleanly created」と別状態として定義しています。現行設計の BEHIND → Update Branch / scope-clean drift → evidence reconciliation / real conflict → hard stop という分離は upstream semantics と一致しています。#2141 を雑に replay executor へ接続すると、この分離を逆に壊します。 (GitHub Docs)

    推奨する reframe

    優先順位は以下です。

    1. 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 をいったん implementation-ready から外し、Allowed Paths を即座に narrow 化する。 少なくとも open-pr/** と implement-issue/** の broad directory allowance は削除候補です。これだけでも 実装: impl-review-loop の runtime_only VC adjudication を current-head evidence に安全に接続する #2467 の不要な直列化を解除できる可能性があります。

    2. 最初の AC を「production state proof」に置き換える。 「どの route/state で」「なぜ既存 update_branch / scope-clean reconciliation では不足し」「どの component が source_base, source_head, expected_remote_pr_head を authoritative に生成するか」をコード上の producer/call-site まで特定することを必須化します。

    3. その state が存在しないなら 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 は not planned が第一候補です。 execute() は explicit operator/recovery utility として残してもよいです。PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 のような例外的な branch reconstruction には実用性があります。production caller が無いというだけで削除を急ぐ必要もありません。

    4. state が本当に存在するなら impl-review-loop に専用 replay_publish action を1本だけ作る。 open-pr には入れず、BEHIND の update_branch も置換しません。producer → route → executor の1本の lifecycle として source_base/source_head/expected_remote_pr_head/current_base_sha を同一 decision cycle に束縛するべきです。

    5. 配線前に executor の reliability debt を同じ Issue へ取り込む。 merge-tree の 0/1/error 分離、TimeoutExpired/OSError 正規化、current-base args の XOR rejection、cleanup warning の返却は、security hardening ではなく「自動処理が無意味に止まらない」ための最低限です。

    6. VC を caller-level に作り直す。 generic rg は廃止し、選定した production adapter を直接 test して、対象 route では execute() が exactly once、それ以外では zero times、ok / blocked / failed が正しく routing されることを検証します。なお executor の実際の成功 status は success ではなく ok です。

    既に Issue コメントではほぼ同方向の REQUEST_CHANGES が出ていますが、その後の issue-refinement-loop は structural_repair_action.apply の transaction_execute_error という control-plane/environment failure で mutation 前に停止しています。つまり、レビューが反証されたのではなく、reframe が Issue 本文へ反映されないまま残っています。

    現時点での推奨 disposition は「#2141 を reframe → production state の存在を fact-check → 存在しなければ not planned」です。 新しい security guard や承認ゲートを増やす方向は勧めません。むしろ未定義の mutation path と broad Allowed Paths を減らすことが、このリポジトリでは品質・有用性・作業速度の3つに効きます。

    必要なら次に、このレビューをそのまま #2141 の OWNER anchor comment として投稿できる形に整理するか、issue-refinement-loop に人間承認なしで reframe させる Claude-GPT 用プロンプトまで作れます。

    ## 結論

    Verdict: REQUEST_CHANGES。Issue #2141 は現状の契約のまま実装へ進めるべきではありません。

    再検証した結果、既存の敵対的レビューで指摘された中心問題は、2026-09-02 時点の main でも解消されていません。特に重要なのは、execute() が死んでいることそのものではなく、「どの production state が、この executor による source-range replay/publish を必要とするのか」が未定義なことです。PR #2118 自身も compute_semantic_ambiguity() には production caller を与えた一方、execute() 本体の caller は follow-up gap として残しています。

    さらに今は #2141 の広い Allowed Paths が、無関係に近い Issue #2467 を「#2141 merge 後まで開始しない」という依存状態にしています。個人開発でワークフロー効率を優先するなら、これは放置コストが実装メリットを上回り始めています。

    敵対的レビュー結果

    Severity Finding 評価
    P0 production caller 以前に input authority producer が存在しない 現行コード検索では expected_remote_pr_head は executor 本体とテストにしか存在しません。source-base の CLI input も executor にしかありません。つまり source_base / source_head / expected_remote_pr_head を「同じ decision cycle の正本」として生成する production component がありません。caller を1行足すだけでは成立しません。
    P0 execute() は Update Branch の代替ではない executor は既存 PR head から detached worktree を作り、source_base..source_head の net diff を git apply して新しい1コミットを追加し、それを lease 付き push します。current base は conflict/final-diff 検査に使うだけで、PR head を current main 上へ作り直す処理ではありません。
    P0 BEHIND には既に canonical executor がある 現行 router は merge_state_status == BEHIND を明示的に implement-issue.update_branch へ route し、verification / PR review を再実行します。GitHub の公式 Update Branch API も base HEAD を PR branch へ merge するための API で、expected_head_sha 不一致は 422 で拒否します。こちらが BEHIND に対する自然な実装です。 ([GitHub Docs]1)
    P0 AC1 / AC2 が false-green Issue の AC1 は generic rg "pr_head_replay_publish_exec" ですが、現行 production code はすでに同 module の compute_semantic_ambiguity() を import しています。したがって execute() を誰も呼ばなくても AC1 が green になります。AC2 も executor 自身の既存テストを実行するだけで caller 配線を証明しません。
    P1 production 化するには executor 自体の reliability 修正が必要なのに Out of Scope _merge_tree_conflicts() は returncode != 0 を全部 conflict としています。しかし Git 公式仕様では 0=clean, 1=conflict, それ以外=実行エラーです。現状では Git 自体のエラーが意味上の conflict に化けます。 (Git)
    P1 subprocess failure が workflow failure ではなく Python crash になり得る replay executor の _run() は timeout=60 を設定する一方、TimeoutExpired / OSError を捕捉しません。対して既存 update_branch.py はこの2つを明示的に正規化しています。自動 caller を付ける前に揃えるべきです。
    P1 partial main-drift args が fail-closed せず通常モードへ downgrade main_drift_reconciliation = bool(current_base_branch and expected_current_base_sha) なので片方だけ渡すと invalid_arguments ではなく reconciliation 無効として処理が進みます。production caller の typo が安全機構を静かに無効化します。
    P1 worktree cleanup failure が完全に捨てられる git worktree remove --force が失敗しても cleanup_error は return result へ載らず、最後に _ = cleanup_error, pushed で捨てられます。頻繁に自動実行するなら .claude/worktrees/ の残骸が運用ノイズになります。セキュリティより実用上の friction として直す価値があります。
    P1 open-pr は lifecycle 上 caller 候補にならない open_pr.py は検証後に gh pr create する PR 作成 wrapper です。一方 replay executor は既存の pr_number, headRefOid, target branch を最初から必要とします。PR 作成前には呼べず、作成直後なら「PRを作ってからそのheadを書き換える」という不自然な順序になります。
    P1 広すぎる Allowed Paths が実際に他 Issue を止めている #2467 は #2141 が .claude/skills/impl-review-loop subtree を広く持っているため、明示的に「#2141 merge 後に開始」としています。まだ caller file すら選定できていない Issue が、別の具体的改善の hard predecessor になっています。これはハーネス由来の実害です。
    P2 executor 自体には operator utility はありそう PR #2070 の conflicting branch recovery では control-plane が exact-old lease と live readback を手動再現して reconciliation しています。したがって「機能自体が完全に無価値」とまでは言えません。ただしこれは 自動 Step 5 action より explicit recovery/operator tool のユースケースを支持する証拠です。

    外部仕様との照合

    現在の replay publisher が使う exact form の --force-with-lease=<ref>:<expect> は、remote ref が指定した <expect> と一致するときだけ update を許可する Git の正式な CAS 機構です。ここへさらに独自 locking・approval artifact・persistent ledger を追加する必要性は低いです。むしろ現在の exact lease を維持したまま mutation path を減らす方が、個人開発では合理的です。 (Git)

    また GitHub 自身が BEHIND を「head ref is out of date」、DIRTY を「merge commit cannot be cleanly created」と別状態として定義しています。現行設計の BEHIND → Update Branch / scope-clean drift → evidence reconciliation / real conflict → hard stop という分離は upstream semantics と一致しています。#2141 を雑に replay executor へ接続すると、この分離を逆に壊します。 ([GitHub Docs]4)

    推奨する reframe

    優先順位は以下です。

    1. 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 をいったん implementation-ready から外し、Allowed Paths を即座に narrow 化する。 少なくとも open-pr/** と implement-issue/** の broad directory allowance は削除候補です。これだけでも 実装: impl-review-loop の runtime_only VC adjudication を current-head evidence に安全に接続する #2467 の不要な直列化を解除できる可能性があります。

    2. 最初の AC を「production state proof」に置き換える。 「どの route/state で」「なぜ既存 update_branch / scope-clean reconciliation では不足し」「どの component が source_base, source_head, expected_remote_pr_head を authoritative に生成するか」をコード上の producer/call-site まで特定することを必須化します。

    3. その state が存在しないなら 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 は not planned が第一候補です。 execute() は explicit operator/recovery utility として残してもよいです。PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 のような例外的な branch reconstruction には実用性があります。production caller が無いというだけで削除を急ぐ必要もありません。

    4. state が本当に存在するなら impl-review-loop に専用 replay_publish action を1本だけ作る。 open-pr には入れず、BEHIND の update_branch も置換しません。producer → route → executor の1本の lifecycle として source_base/source_head/expected_remote_pr_head/current_base_sha を同一 decision cycle に束縛するべきです。

    5. 配線前に executor の reliability debt を同じ Issue へ取り込む。 merge-tree の 0/1/error 分離、TimeoutExpired/OSError 正規化、current-base args の XOR rejection、cleanup warning の返却は、security hardening ではなく「自動処理が無意味に止まらない」ための最低限です。

    6. VC を caller-level に作り直す。 generic rg は廃止し、選定した production adapter を直接 test して、対象 route では execute() が exactly once、それ以外では zero times、ok / blocked / failed が正しく routing されることを検証します。なお executor の実際の成功 status は success ではなく ok です。

    既に Issue コメントではほぼ同方向の REQUEST_CHANGES が出ていますが、その後の issue-refinement-loop は structural_repair_action.apply の transaction_execute_error という control-plane/environment failure で mutation 前に停止しています。つまり、レビューが反証されたのではなく、reframe が Issue 本文へ反映されないまま残っています。

    現時点での推奨 disposition は「#2141 を reframe → production state の存在を fact-check → 存在しなければ not planned」です。 新しい security guard や承認ゲートを増やす方向は勧めません。むしろ未定義の mutation path と broad Allowed Paths を減らすことが、このリポジトリでは品質・有用性・作業速度の3つに効きます。

    必要なら次に、このレビューをそのまま #2141 の OWNER anchor comment として投稿できる形に整理するか、issue-refinement-loop に人間承認なしで reframe させる Claude-GPT 用プロンプトまで作れます。

  7. squne121 commented on Sep 2, 2026

    @squne121
    OwnerAuthor

    確認した範囲では、#2141 はまだ元の「production caller を配線する」契約のまま OPEN です。 一方、直前の refinement は structural_repair_action.apply の transaction_execute_error で mutation 前に停止しており、その調査では production replay を必須とする state は見つかっていません。 最新 OWNER コメントも、第一候補を 「reframe → production state を fresh fact-check → 存在しなければ not planned」 としています。

    したがって、今回は「caller を作る方向へ誘導」せず、fresh evidence が同じ結論なら Claude Code 自身に not planned まで処理させるのを推奨します。#2467 は現在も本文上 #2141 merge 後に開始 としており、#2141 の broad Allowed Paths が実際の直列化要因になっています。

    #2141 (comment)

    を operator_asserted_human_context の OWNER anchor として扱い、Issue #2141 に対して issue-refinement-loop を実行してください。

    目的は、現在の Issue 本文を前提に無理に implementation-ready にすることではありません。anchor comment の REQUEST_CHANGES を fresh current-main evidence で検証し、Issue #2141 を最も合理的な disposition へ収束させることです。

    実行方針

    • issue-refinement-loop の canonical workflow / SSOT / command registry / routing に従うこと。
    • anchor_comment_url は上記 URL を使用すること。
    • human-context lane が必要な箇所では preflight.run.with_human_context 等、現在の canonical profile を使用すること。
    • raw comment を独自に authority として再解釈せず、canonical preflight / planner / fact-check / scope-delta machinery に正規化させること。
    • routine な判断、iteration 継続、rewrite、Issue body 更新、label hygiene、canonical な dependency 更新について私への承認確認を挟まないこと。
    • needs_fix は iteration 上限まで自動継続すること。今回は最大 5 iteration まで許可する。
    • 「この修正を適用してよいですか」「Issue を更新してよいですか」「次へ進んでよいですか」等の確認は不要。
    • ただし repository の hard policy が明示的に禁止している操作を permission bypass で回避してはならない。真に解消不能な hard blocker のみ最終停止理由にできる。

    最優先で検証する仮説

    最新 anchor の中心仮説を fresh current-main で再検証すること。

    1. pr_head_replay_publish_exec.py::execute() を必要とする production state transition が本当に存在するか。
    2. source_base, source_head, expected_remote_pr_head および必要な current-base authority を、同一 decision cycle で authoritative に生成する production producer が存在するか。
    3. BEHIND は既存 implement-issue.update_branch で処理されており、replay executor を必要としていないか。
    4. scope-clean main drift は evidence reconciliation で処理され、branch replay mutation を必要としていないか。
    5. normal publish / PR creation lane に replay executor を差し込む必然性があるか。
    6. PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 のような利用例が production automatic routing の根拠なのか、それとも explicit operator/recovery utility の利用例に留まるのか。

    既存レビューの結論を盲信せず、current main、関連 Issue / PR / comments、production call sites、tests、design references を read-only に調査して裏付けること。

    SubAgent の使用

    調査は必要に応じて codebase-investigator SubAgent に委譲すること。

    外部仕様が disposition に影響する場合のみ、planner / skill contract に従って web-researcher を使用してよい。

    重要:

    • SubAgent を background 起動しただけで完了扱いにしないこと。
    • 必須 SubAgent の completion notification / final result が返るまで待つこと。
    • spawn evidence を completion evidence と混同しないこと。
    • required SubAgent が in_progress / running / background 実行中の状態で次の routing decision や最終回答へ進まないこと。
    • 複数 SubAgent を並列化できる場合は並列化してよいが、全 required result を join してから判断すること。
    • SubAgent に nested SubAgent delegation をさせないこと。
    • Issue mutation authority は root/main control-plane に保持すること。

    推奨 disposition

    fresh fact-check の結果に基づき、以下を優先順位として機械的に選択すること。

    A. production replay state が存在しない場合 — 第一候補

    Issue #2141 を not planned に収束させる。

    この場合:

    B. production replay state が実在する場合

    #2141 を implementation-ready へ直接戻さず、まず proof-first contract に reframe する。

    少なくとも以下を contract に反映すること。

    • production state / route を exact に定義する。
    • authoritative input producer を exact component / call site まで特定する。
    • caller は原則 impl-review-loop の専用 replay_publish 相当 action 1本に限定する。
    • open-pr を caller 候補から除外する。
    • BEHIND -> update_branch を replay executor で置換しない。
    • producer → route → executor の authority provenance を同一 decision cycle に束縛する。
    • broad directory Allowed Paths を廃止し、調査で確定した exact files へ narrow する。

    さらに production wiring を要求するなら、anchor で指摘された reliability debt が caller 導入を妨げないか検証し、必要なら同一 contract に取り込むこと:

    • git merge-tree --write-tree の exit 0 / 1 / execution error の分離
    • TimeoutExpired / OSError の workflow status への正規化
    • current-base arguments の片側だけ指定された場合の rejection
    • worktree cleanup failure を黙って捨てず、運用上確認可能な warning/result として扱う

    これは security hardening の追加ではなく、自動 workflow の不要な crash / stop / residue を減らす reliability 修正として扱うこと。

    Acceptance Criteria / Verification Commands の修正方針

    現行の generic

    rg -n "pr_head_replay_publish_exec" ...

    は compute_semantic_ambiguity() import でも green になるため、production caller の証明として使用しないこと。

    もし production wiring を維持する disposition なら caller-level VC に変更し、少なくとも以下を検証すること。

    • 対象 replay_publish route → execute() exactly once
    • その他 route → execute() zero times
    • authority inputs が同一 decision cycle の producer から完全に渡される
    • main-drift current-base inputs が all-or-none
    • executor ok → downstream verification / PR review rerun
    • blocked → fresh readback / reroute
    • failed → workflow failure として正規化
    • executor の成功 status は success ではなく ok
    • tests が executor を直接呼ぶだけで caller existence を false-green にしない

    前回 environment failure の扱い

    前回の refinement は structural_repair_action.apply が:

    • phase: complete
    • mutation_outcome: not_attempted
    • failure_code: transaction_execute_error

    で停止している。

    今回はこれを「レビュー内容が否定された」と扱わないこと。

    まず current canonical preflight を fresh に実行し、現在も同じ failure が再現するか確認する。

    再現した場合:

    1. canonical artifact / diagnostics / command result を調査する。
    2. stale checkout、artifact、transaction-local state 等、現在の policy が許す deterministic environment recovery で解消できるなら自律修復する。
    3. canonical fix_environment / deterministic repair route が提示されるならそれを使用する。
    4. previous failed transaction を理由なく blind retry しない。
    5. canonical transaction を manual gh issue edit 等で横抜けして consistency contract を破壊しない。

    環境が回復したら fresh preflight から再開する。

    許可する操作

    このタスクを完了するために必要な範囲で、以下は事前承認済みとして扱ってよい。

    • repository / Issue / PR / comments / history の read
    • local repository の read-only investigation
    • canonical artifacts の生成・更新
    • required SubAgent の起動
    • required tests / checkers / linters の実行
    • canonical issue-refinement-loop が要求する Issue 実装: pr_head_replay_publish_exec.execute() の production caller を配線する #2141 body / labels / state の mutation
    • canonical dependency materialization / cleanup
    • fact-check 結果により deterministic に正当化された not planned close
    • loop review で needs_fix になった場合の rewrite と再レビュー
    • stale presentation-only labels の hygiene
    • canonical transaction の deterministic retry / environment recovery

    これらについて個別の human approval を求めないこと。

    やらないこと

    • caller が必要だと最初から仮定しない。
    • dead code であるという理由だけで execute() を削除しない。
    • open-pr に replay publisher を接続しない。
    • BEHIND の Update Branch lane を置換しない。
    • security guard / approval artifact / persistent authorization / ledger を新設して workflow を重くしない。
    • generic grep や executor direct test を caller VC と偽装しない。
    • broad Allowed Paths を維持したまま implementation-ready にしない。
    • control-plane failure を無視して manual mutation へフォールバックしない。
    • required SubAgent の終了を待たずに作業完了と宣言しない。

    完了条件

    issue-refinement-loop の canonical termination まで進めること。

    望ましい最終状態は fresh evidence に応じて次のいずれか。

    途中の「調査完了」「SubAgent 起動済み」「Issue body 更新済み」は完了ではない。

    最後に以下を簡潔に報告すること。

    人間への途中承認要求は行わず、自律的に canonical loop を最後まで進めてください。

    この形なら、前回と同じ transaction_execute_error に遭遇した場合にも「待つ/人間に聞く」ではなく、まず deterministic recovery を試しつつ、manual rewrite で canonical transaction を迂回する事故も防げます。また、最新コメントの evidence が再現されれば、実装 Issue を無理に延命せず not planned まで進める指示になっています。

  8. squne121 commented on Sep 2, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: disposition = not planned

    Fresh fact-check(current main、read-only investigation)

    anchor の中心仮説を codebase-investigator で再検証した結果:

    1. pr_head_replay_publish_exec.py::execute() の production caller は存在しない。 rg -n "pr_head_replay_publish_exec" --type py -g '!**/tests/**' . にヒットするのは run_refinement_preflight.py / plan_issue_scope_rollup.py のコメント参照のみで、実際に execute() を呼ぶ非テストコードは無い。route_loop_verdict_v2.py が import しているのは同モジュールの compute_semantic_ambiguity() のみ(PR fix(loop): main drift evidence を再束縛する (#2102) #2118 で既に production caller 獲得済み、対象外)。
    2. source_base / source_head / expected_remote_pr_head を同一 decision cycle で authoritative に生成する production producer は存在しない。 これら識別子は pr_head_replay_publish_exec.py 自身(関数引数・CLI)以外のどこにも定義されていない。
    3. BEHIND は既存 implement-issue.update_branch 相当(route_loop_verdict_v2.py の route_to_update_branch fast-path)で処理されている。 replay executor を必要としない。
    4. scope-clean main drift は evidence re-acquisition(.claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md)で reconciliation されており、pr_head_replay_publish_exec.execute() を経由しない。
    5. open-pr / implement-issue の publish lane に pr_head_replay_publish_exec への参照・接続の必然性を示す既存コードは無い。 open-pr は PR 作成前提の wrapper であり、replay executor が要求する既存 pr_number / headRefOid と lifecycle 順序が合わない。
    6. PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 は自動 production routing の例ではない。 実際には「既に main に同一内容が landing 済み」として differential なしで除去された変更であり、その由来の PR fix-bootstrap-refs #2081 は Draft のまま merge されていない。explicit operator/recovery 用途の根拠として弱く、production wiring の先例にはならない。

    これにより、anchor が提示した「production replay state が存在しない場合」の条件が fresh evidence で成立していると判断する。

    Disposition

    Issue #2141 を not planned として収束させる。

    • pr_head_replay_publish_exec.py::execute() はコード変更しない。production caller が無いことのみを理由に削除しない。PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 の recovery 事例が示すとおり、explicit operator/recovery utility として残す。
    • 新規の production mutation path、approval gate、security artifact、persistent ledger は追加しない。
    • 広い Allowed Paths(.claude/skills/impl-review-loop/**、.claude/skills/open-pr/**、.claude/skills/implement-issue/** の broad directory allowance)に起因する不要な overlap / dependency blocking を close により解消する。

    #2467 への影響

    Issue #2467 の本文は native GitHub dependency(blockedBy/trackedIssues)ではなく、prose 上の #2141 merge 後に開始する という記述にのみ依存している(GraphQL 確認: trackedIssues/trackedInIssues は空)。#2141 が not planned で close されるため、この prose dependency は stale になる。issue-editor 経由で該当箇所のみを narrow に修正し、#2467 が #2141 merge を待たず着手可能である旨へ更新する。

  9. removed
    triage-required
    on Sep 2, 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/implementerenhancementfollow-upphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions