Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させ、通常の post-merge cleanup 手順(orchestrator → worker → executor → CLI)から入力を届けて Refs-bound PR の worktree/branch cleanup 恒常拒否を解消する"
change_kind: workflow
dedupe_key: "cleanup-exec:linked-issue:non-closing-authority:v1"Parent Issue
none(単独改善。発見元: #2878 の refinement 終了コメント #2878 (comment) の finding 3)
Parent Goal Ref
- Goal: non-closing な
Refs #Nで意図的に OPEN を保つ Issue を持つ PR でも、post-merge cleanup が安全に worktree/branch を片付けられるようにする。 - Desired Destination: N/A(単独改善。実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の write-capable scope は引き継がない)。
Current Validated Scope
検証基準: main fc34b8d6be5f6f110aaa7552bd2127fb590054dc(2026-10-04 fresh 確認)。
- 依存 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 は CLOSED、実装 PR feat: PR の Closes/Refs 選択と post-merge OPEN close gate を単一の reference authority evaluator で整合する (#2878) #2896 は MERGED(2026-10-03)。依存待ちは blocker ではない。
scripts/agent-ops/cleanup_exec.py::_verify_linked_issueはlinked_issue_numberがclosingIssuesReferencesに含まれる場合(fast path、追加 Issue fetch なし)、または 実装: cleanup_exec.py が research issue(closing keyword不使用)のPRに対してlinked_issue_mismatchで恒常的にworktree/branch cleanupを拒否する問題を修正する #2508 research fallback(Refs #N+issue_kind: research+ CLOSED/COMPLETED)の場合のみ認可し、それ以外はLINKED_ISSUE_MISMATCHを返す。non_closing_authorityを参照する箇所は無い。_verify_linked_issueの呼び出し元はverify_cleanup_authorizationとverify_branch_only_cleanup_authorizationの 2 箇所。run()は同一reqを、初回認可と、worktree remove 成功後にbranch -dが失敗した場合の同一 invocation 内 branch-only 再認可の両方に渡す。再認可が拒否された場合は、成功済みworktree_removeをactions_takenに残し、元のbranch_delete_failedを保持し、branch を残す(既存の部分成功契約)。cleanup_exec.py main()の CLI 引数は--pr-number/--linked-issue-number/--worktree-path/--branch-name/--jsonのみで、reqに authority は入らない。_pr_state()はbodyを既に fetch している(本文専用の新しい API 呼び出しは不要)。- 実際の削除コマンドは
.claude/skills/post-merge-cleanup-executor/SKILL.mdの cleanup 手順(cleanup_exec.py呼び出し)に記載され、worker(.claude/agents/post-merge-cleanup-worker.md)は executor Skill だけを読み、入力はmerged_pr_numberとlinked_issue_numberのみ。worker は Edit/Write を持たないため、authority は orchestrator が保存したファイルのパスとして受け渡す。orchestrator 側は既に--snapshot-file/--cleanup-receipt-fileのファイル受け渡し規約を持つ。 non_closing_authorityの 7 key(decision/level/reason_code/repo/issue_number/pr_number/pr_body_sha256。live なissue_stateを含まない)と検証は 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 が.claude/skills/open-pr/scripts/open_pr.py::non_closing_authority_binds(producer 側)と.claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py::_non_closing_authority_binds(adapter 側)に実装済みで、parity regression で整合を保っている。A1/A2 は evaluator 実行時に対象 Issue が OPEN だったことを意味する。- discard lane(
verify_discard_authorization)はcleanup_exec.pyの CLI に公開されておらず、scripts/agent-ops/materialize_cleanup_contract.pyの--check/--consume(--operation local_only_discard)経由の Python entry である。既存 subprocess regression はscripts/agent-ops/tests/test_cleanup_exec_issue_2628_e2e.pyにある。 .claude/skills/post-merge-cleanup/SKILL.mdとdocs/dev/workflow.mdは「実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 までRefs-bound PR の削除系 cleanup はLINKED_ISSUE_MISMATCHで停止」と記載し、tests/test_post_merge_cleanup_boundary.py(#2891/LINKED_ISSUE_MISMATCH/cleanup_exec.py::_verify_linked_issueの文字列を assert)がそれを固定している。- CI の Python test plan は
scripts/agent-ops/tests/をディレクトリ単位で、tests/test_post_merge_cleanup_boundary.pyを個別に収集済みで、新テストの配置に CI 定義の変更は不要。 scripts/agent-guards/worktree_scope_guard.pyにはcleanup_exec.py専用の exact argv allowlist があるが、現行の.claude/settings.jsonには登録されていない(非活性)。着手時にこの状態を再確認し、活性化されていた場合は Stop Conditions に従う。--phase recover/--phase local-onlyの Task Context adapter は non-closing binding を受理しない(実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の仕様)。
Remaining Parent Gaps
なし(単独改善)。
Background
#2878 実装後、Refs-bound PR は Task Context adapter(--phase merged/completed)では non_closing_authority で bind される。しかし post-merge-cleanup が worker に linked_issue_number を渡して cleanup_exec を実行すると LINKED_ISSUE_MISMATCH で恒常的に拒否される(削除なし・安全側停止)。root cause は、linked Issue 認可が closing relation(GitHub の auto-close 関係)を identity 兼 authority として使い、non-closing Refs #N の OPEN Issue を識別できない点にある。さらに、helper だけを直しても、通常の cleanup 手順から authority を CLI に届ける入力経路が存在しなければ実運用は拒否されたままになる。
運用 workaround(linked_issue_number の省略、closingIssuesReferences を偽装するための PR 本文の Closes への書き換え)は live evidence 前の誤 close を招くため不採用。決定論的修正として、#2878 が固定した 7 key の non_closing_authority を orchestrator-attested な入力として、production の入力経路と認可の両方に加える。
分離理由: #2878 の Outcome は Task Context cleanup binding(adapter)までに限定される。cleanup_exec の認可は別 Outcome・別 Allowed Paths である。#2508 は research issue 限定の fallback、#1196 は branch-only lane 追加で Outcome が異なる。recover / local-only の non-closing 対応は別 Outcome(Out of Scope 参照)。
dedupe evidence: 2026-10-03 に OPEN/CLOSED 両方を cleanup_exec linked_issue_number Refs closingIssuesReferences 等で検索し、同一 Outcome を所有する Issue が無いことを確認済み。
Outcome
通常の post-merge cleanup 手順で、orchestrator が保存した検証済み non_closing_authority(7 key)が worker → executor Skill の実コマンド → cleanup_exec.py の production CLI → req → 初回認可 → branch-only 認可 → 同一 invocation 内の branch-only 再認可まで届き、Refs-bound PR の worktree/branch cleanup が認可される状態にする。authority が無い、または検証に失敗した場合は従来どおり LINKED_ISSUE_MISMATCH で拒否する。既存の closing relation と #2508 research fallback の挙動は変えない。
入力経路は既存の --snapshot-file 規約に合わせ、cleanup_exec.py に任意の --non-closing-authority-file <path>(7 key の JSON object を保存したファイル)を 1 つ追加する形とする。この exact な入口を、worker 入力・executor Skill のコマンド・テストで一致させる。
Runtime Verification Applicability
decision: immediate
reason: >-
Allowed Paths の `scripts/agent-ops/**`・`.claude/skills/**/SKILL.md`・`.claude/agents/**` は
docs/dev/extension-surface-runtime-policy.yaml の hard selector
(`subagent-lifecycle-causal-evidence-smoke` / `skill-invocation-runtime-smoke` /
`subagent-delegation-runtime-smoke`)に該当し、`default_decision: immediate` である。cleanup_exec は
worktree/branch 削除に至る認可経路であり、production CLI を subprocess で起動した fail-closed 挙動の確認も必要。
runtime smoke は既存 runner(scripts/agent-ops/run_worktree_agent_runtime_smoke.py --mode structured)のみを使い、
新 runner・新 harness・新 approval layer は作らない。Skill の正式 load を no-mutation で行う既存経路は runner に無いため、
smoke は delegation と観測範囲を限定した合成 dry-run に限り、production worker の業務意味の実行は証明しない
(意味の一致は AC1〜AC6 の pytest と pr-review-judge の責務)。
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC8]
execution_environment: Linux、uv、pytest、current-head LOOP_PROTOCOL worktree と current Claude Code runtime。`cleanup_exec.py` の pytest は fake gh と一時 git repo を使う hermetic な subprocess で起動し(`test_cleanup_exec_issue_2628_e2e.py` の fixture 方式を踏襲)、実 repo の worktree/branch は削除しない。AC8 は既存 runner を `--mode structured` で実行し、fixture(prompt と output schema)は GitHub mutation・secret・destructive action を伴わない合成 read-only dry-run のみとする。
skip_conditions: uv / pytest が利用できない場合は、AC1〜AC5 の runtime VC を `environment_blocked` として PR に記録して STOP し、PASS へ変換しない(専用の終了コードや harness は新設しない)。`claude` 実行ファイルまたは `uv` が利用不能な場合は、AC8 を docs/dev/runtime-verification-policy.md の SKIP 規約(exit 77 + stdout 先頭 `SKIP:`)で停止し PASS 扱いしない。
fallback_policy: Python request への直接注入や関数直呼びの成功を AC1〜AC5 の runtime PASS の代用にしない。AC1〜AC7 の静的検査・PR review の PASS を AC8 の代替にしない。AC8 は汎用 read-only 委譲先 `Explore` への delegation の実在、観測条件付き marker の順序、既存出力契約 `POST_MERGE_CLEANUP_REPORT_V1` の必須 field の形を満たす合成 JSON、SubAgent start/stop の causal evidence の相関だけを主張する。
artifact_requirements: PR の Runtime Verification Evidence に、AC1〜AC5 の実行コマンド・exit code・pytest 結果要約と、AC8 の runner の bounded な evidence(current-head identity、Claude Code 版、causal_evidence_source、結果)を機密なしで引用する。raw transcript・secret は記載しない。新しい artifact 形式は追加しない。
runtime_assertion_bindings:
- profile: skill-invocation-runtime-smoke
assertion: procedure_steps_executed_in_declared_order
ac: AC8
- profile: skill-invocation-runtime-smoke
assertion: output_contract_schema_fields_present
ac: AC8
- profile: subagent-delegation-runtime-smoke
assertion: delegation_target_actually_invoked
ac: AC8
- profile: subagent-delegation-runtime-smoke
assertion: permission_mode_effective_behavior_matches_parent_classifier
ac: AC8
- profile: subagent-lifecycle-causal-evidence-smoke
assertion: subagent_start_stop_causal_evidence_correlated
ac: AC8runtime smoke fixture の制約(false evidence を作らない)
- output schema の required field は実在する出力契約
POST_MERGE_CLEANUP_REPORT_V1(.claude/skills/post-merge-cleanup-executor/SKILL.mdが定義)の既存必須 field のみとし、存在しない field・enum を作らない。 - ordered marker は prompt が SubAgent に echo させるだけの自己申告を semantic proof としない。causal evidence は
hook_id_correlated(runner のsubagent_causal_evidence_verdict())であることを必要条件とする。 - 既存 runner だけで安全かつ正直に実証できない場合は、新 harness を作らず Stop Conditions に従い停止する。
- smoke の委譲先は production の agent 契約と衝突しない既存 agent(
Explore)とし、post-merge-cleanup-worker等の production custom agent を fixture のために流用しない。
In Scope
cleanup_exec.py main()に任意の--non-closing-authority-fileを追加し、読み込んだ JSON object をreq["non_closing_authority"]に載せる。ファイルが読めない・JSON object でない場合は authority 未供給と同じ扱い(新 reason code なし)にする。未指定時の挙動は完全に従来どおり。_verify_linked_issueに新しい認可 path を追加する。評価順は、既存の closing relation fast path、既存の 実装: cleanup_exec.py が research issue(closing keyword不使用)のPRに対してlinked_issue_mismatchで恒常的にworktree/branch cleanupを拒否する問題を修正する #2508 research fallback の順で認可されなかった場合のみ、non-closing authority を評価する(research fallback のgh issue viewfetch が失敗・timeout・OPEN のいずれでも、既存どおり False として扱い authority 評価へ fall through する。hermetic な fake gh はgh issue viewにも応答する)。この path はclosingIssuesReferencesが空の場合に限り評価し、別 Issue の closing node がある場合は fall through しない。検証内容は 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の 7 key 契約と同一(decision == nonclosing_required、level A1/A2、repo(大文字小文字を区別しない)・issue・PR 番号の一致、pr_body_sha256が_pr_state()で取得済みのbodyの UTF-8 bytes(.strip()や改行変換なし)の SHA-256 と一致、型は bool/文字列/list/object を拒否。PR body の欠落・None・非 string も拒否)。level: CLOSED/ A3 等は拒否する。7 key の意味は 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 から再定義せず、open_pr.non_closing_authority_bindsと同じ判定の最小の twin をcleanup_exec.pyに置き、新テストで両者の parity を確認する。- 呼び出し 2 箇所で authority を含む同一
reqが使われることを維持し、同一 invocation 内の branch-only 再認可も同じ authority を再評価する(再取得した PR 本文の hash が変わっていれば拒否される)。 .claude/skills/post-merge-cleanup-executor/SKILL.mdの cleanup コマンドに任意の--non-closing-authority-fileを追記する。.claude/agents/post-merge-cleanup-worker.mdの入力一覧に任意のnon_closing_authority_file(パス)を追加する(手順本体は複製しない)。.claude/skills/post-merge-cleanup/SKILL.mdに、orchestrator が fresh evaluator の 7 key(snapshot の top-levelnon_closing_authorityと同一の写像)を、evaluator のbody_verdictがvalidの場合だけファイルとして保存し(未検証の evaluator 結果は保存しない。decision == nonclosing_requiredだけを根拠にしない)、worker に渡す手順を追記する。ファイルの置き場・寿命は既存の--snapshot-file/--cleanup-receipt-fileの一時 path 規約に従う。あわせて、「実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 まで停止」の既知制限を、解消した範囲と残る制限(Out of Scope)に書き換える。docs/dev/workflow.mdの同旨の既知制限を更新する。tests/test_post_merge_cleanup_boundary.pyの旧制限 assertion を、新しい入力経路と残る制限の文書契約に更新する。- production CLI を subprocess で通す regression test
scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.pyを追加する。 - runtime smoke 用 fixture(prompt と output schema)を
.claude/skills/post-merge-cleanup-executor/tests/fixtures/配下に 最大 2 ファイルだけ追加する(hard selector の readiness を満たすための最小 scope 拡張であり、production implementation scope の拡張ではない)。
Out of Scope
verify_discard_authorization(discard lane)の変更、および discard 用の CLI や harness の新設。- 新 reason code、新 schema、新しい汎用 validation / authorization framework、rollback 機構、自動 close 実行器の追加。
--phase recover/--phase local-onlyの non-closing 対応(Task Context adapter 側の別 Outcome。本 Issue 完了後も残る制限として docs に明記する)。- cleanup 実行時に live Issue state を再 fetch して CLOSED を拒否する責務の追加。evaluator 実行後に Issue が CLOSED になった場合の扱いは変更しない(運用順序は cleanup 完了 → post-merge 証跡確認 → Issue close)。
- 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 / 実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 / fix: trusted human-context contract-update の安全性と producer 到達性を修正 #2861 の変更と、
non_closing_authorityの 7 key の再定義。 - 実装: cleanup_exec.py が research issue(closing keyword不使用)のPRに対してlinked_issue_mismatchで恒常的にworktree/branch cleanupを拒否する問題を修正する #2508 research fallback と closing relation 経路の挙動変更。
Acceptance Criteria
- AC1: executor Skill に記載した argv と同じ
--non-closing-authority-fileを production CLI(cleanup_exec.pyの subprocess 起動)に渡すと、有効な authority(decision == nonclosing_required、level A1 または A2、pr_body_sha256・repo・issue・PR 番号が一致、closing node なし)を持つ Refs-bound PR について、通常 lane と branch-only lane の両方でlinked_issue_numberが認可され、実際の一時 worktree/branch の状態が期待どおりになる。Python request への直接注入だけでは AC1 を満たさない。 - AC2: 最初の破壊的操作より前の拒否: authority 欠落、ファイル不正、key 集合の過不足、
pr_body_sha256不一致(末尾改行・CRLF の差を含む)、issue / PR 番号 / repo 不一致、型不正(levelの list/object、番号の bool/文字列、PR body の欠落・None・非 string)、levelが A3 またはCLOSEDのいずれの場合も、新 reason code を追加せず従来のLINKED_ISSUE_MISMATCHで拒否し、削除を行わずactions_takenは空である。別 Issue の closing node がある場合も拒否される。あわせて、同一の入力 fixture 群をopen_pr.non_closing_authority_bindsとcleanup_exec.py側の twin の両方に流し、判定が一致する(parity)。 - AC3: 既存挙動の不変: authority を渡さない場合、closing relation fast path(追加 Issue fetch なし)と 実装: cleanup_exec.py が research issue(closing keyword不使用)のPRに対してlinked_issue_mismatchで恒常的にworktree/branch cleanupを拒否する問題を修正する #2508 research fallback(CLOSED/COMPLETED)は従来どおり認可され、authority 欠落が入口全体の拒否条件にならない。authority を併せて渡しても、既存 path で認可される場合の結果は変わらない。
- AC4: 途中成功の保持: 通常 lane で初回認可後に worktree remove が成功し
branch -dが失敗して、同一 invocation 内の branch-only 再認可が authority / hash 不一致で拒否される場合、成功済みworktree_removeをactions_takenに残し、元のbranch_delete_failedを保持し、branch を残し、force delete を実行しない。この場合に「authority 拒否のため削除ゼロ」と扱わない。テストの fake gh は PR 本文の取得ごとに本文を切り替えられる(初回は authority と一致、再認可時は不一致)stateful な実装とし、2 回目の取得が実際に行われたことを呼び出し記録で確認する。fixture は worktree remove 成功後にbranch -dが失敗する branch(未 merge 判定)を使い、既存test_cleanup_exec_issue_2628_e2e.pyの fake gh を踏襲・拡張する範囲に留める。 - AC5: discard lane は authority が与えられても
verify_discard_authorizationの挙動が変わらない(authority を含む request に対する小さな関数単位のテスト)。discard の production entrypoint(materialize_cleanup_contract.pyの--check/--consume)の既存 subprocess regression(test_cleanup_exec_issue_2628_e2e.py)が引き続き PASS する。cleanup_exec.pyに discard 用の CLI は追加しない。 - AC6: orchestrator Skill・worker・executor Skill・
docs/dev/workflow.md・boundary test の記述が、受け渡し経路(--non-closing-authority-file)と残る制限(recover/local-onlyは未対応)で一致し、「実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 まで停止」の旧制限文言が残らず、「全 recovery path が解禁された」とは書かれていない。orchestrator Skill には authority file をbody_verdict == validの場合だけ保存する条件文が含まれ、boundary test がその存在を検証する。 - AC7: 既存の cleanup_exec 関連テストと型・lint が PASS し、
cleanup_exec.pyに新 reason code が追加されていない。 - AC8: 既存 runner(
--mode structured)で、read-only の合成 dry-run を汎用 read-only 委譲先Exploreへ foreground 委譲し、(i) 子が改訂後の executor Skill / worker 定義を Read した観測に条件付けた宣言順 marker(POST_MERGE_CLEANUP_SMOKE_STEP_DOCS_READ→POST_MERGE_CLEANUP_SMOKE_STEP_ARGV_OBSERVED→POST_MERGE_CLEANUP_SMOKE_STEP_SHAPE_EMITTED)、(ii) 親の最終出力が既存出力契約POST_MERGE_CLEANUP_REPORT_V1の必須 field の形を満たす合成 JSON であること、(iii) SubAgent の start / stop の causal evidence が実 delegation と相関することを実 runtime で確認する。この smoke はpost-merge-cleanup-workerの正式 load・手順の業務意味の実行を証明しない(意味の一致は AC1〜AC6)。SKIP は PASS ではない。
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_cli_authorized_non_closing_normal_lane
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_cli_authorized_non_closing_branch_only_lane
# AC2
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_rejected_before_first_destructive_operation
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_authority_twin_parity_with_open_pr
# AC3
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_unchanged_existing_paths_without_authority
# AC4
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_partial_success_preserved_when_reauthorization_rejected
# AC5
# baseline-expect: fail
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py::test_discard_lane_unchanged_with_authority
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec_issue_2628_e2e.py
# AC6
$ uv run --locked pytest -q tests/test_post_merge_cleanup_boundary.py
# AC7
$ uv run --locked pytest -q scripts/agent-ops/tests/test_cleanup_exec.py
$ uv run --locked pytest -q tests/codex/test_cleanup_exec_branch_only.py
$ pnpm typecheck
$ pnpm lint
# AC8
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree . --prompt-file .claude/skills/post-merge-cleanup-executor/tests/fixtures/issue_2891_non_closing_authority_runtime_smoke.prompt.md --output-dir artifacts/runtime-smoke/issue-2891 --evidence-json artifacts/runtime-smoke/issue-2891.evidence.json --require-subagent-causal-evidence --expect-marker POST_MERGE_CLEANUP_NON_CLOSING_SMOKE_OK --expect-ordered-marker POST_MERGE_CLEANUP_SMOKE_STEP_DOCS_READ --expect-ordered-marker POST_MERGE_CLEANUP_SMOKE_STEP_ARGV_OBSERVED --expect-ordered-marker POST_MERGE_CLEANUP_SMOKE_STEP_SHAPE_EMITTED --output-schema-path .claude/skills/post-merge-cleanup-executor/tests/fixtures/issue_2891_non_closing_authority_runtime_smoke.output.schema.json注: 新規テストの VC は、未作成のテストファイルへの node-id で記述している(baseline では pytest が file not found で失敗する)。テスト名は上記の node-id と一致させる。
Allowed Paths
- scripts/agent-ops/cleanup_exec.py
- scripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py
- .claude/skills/post-merge-cleanup/SKILL.md
- .claude/skills/post-merge-cleanup-executor/SKILL.md
- .claude/agents/post-merge-cleanup-worker.md
- docs/dev/workflow.md
- tests/test_post_merge_cleanup_boundary.py
- .claude/skills/post-merge-cleanup-executor/tests/fixtures/issue_2891_non_closing_authority_runtime_smoke.prompt.md
- .claude/skills/post-merge-cleanup-executor/tests/fixtures/issue_2891_non_closing_authority_runtime_smoke.output.schema.json
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合(
non_closing_authorityの 7 key・意味・型定義を含む) - 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 実装着手時点の main で、
open_pr.non_closing_authority_bindsと adapter の 7 key 契約が本 Issue の Current Validated Scope と異なっている場合は着手せず停止する(実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 / feat: PR の Closes/Refs 選択と post-merge OPEN close gate を単一の reference authority evaluator で整合する (#2878) #2896 自体は完了済みで待機理由にならない)。 - 新 reason code・新 schema・discard lane の変更・live Issue state の再 fetch が必要と判明した場合は停止する。
Required Skills
なし
Required Design References
- docs/dev/workflow.md
- docs/dev/runtime-verification-policy.md
- docs/dev/task-context.md
Scope Delta
N/A。ただし 2026-10-04 の OWNER レビュー #2891 (comment) の指摘(production 入力経路、CLOSED の意味、Allowed Paths、途中成功と discard の検証)を反映し、executor Skill・worker・workflow docs・boundary test を Allowed Paths に追加した(同一 Outcome の配線のための最小拡張)。
Delivery Rule
1 Issue = 1 PR。専用 worktree を使い Draft PR 既定。#2878 / PR #2896 は完了済みで、先行依存は無い。
Notes for Reviewer
scripts/agent-ops/** は extension-surface policy の hard selector に該当するため decision は immediate とした。#2878 は本 Issue で mutation しない。入口名 --non-closing-authority-file は既存の --snapshot-file / --cleanup-receipt-file 規約と整合する最小の入口として選んだ。
Activity
squne121 commentedon Oct 4, 2026
結論:Issue 契約に対して
REQUEST_CHANGES相当です修正の方向は適切です。ただし、現在の #2891 は「認可 helper が受理できること」と「通常の cleanup 手順から、その入力を届けて完了できること」の間が抜けています。 大きな認可基盤や新しいハーネスを追加する必要はありません。実際の入力経路、CLOSED の扱い、途中失敗時の期待値を明確にする、小さな契約修正を勧めます。
確認時の #2891 は OPEN、コメントなしです。依存する #2878 の実装 PR #2896 はマージ済みなので、依存の完了待ちは不要です。コードは
fc34b8d6be5f6f110aaa7552bd2127fb590054dcを基準に確認しました。#2878 の発見元コメント、PR #2896 のレビューコメントと実装、#2508 の research fallback 契約、現在の executor・worker・Task Context adapter・関連テストを照合しています。以下は、確認できた実装上の事実と、そこから判断した Issue 契約の不足を分けたレビューです。
不正な型の fixture は、
levelの list/object、番号の bool/文字列など、既存 #2878 が既に対処した境界を小さく再利用すれば足ります。新しい一般化された validation framework は不要です。最後に、この修正だけで、Refs PR のあらゆる復旧経路が解禁されるわけではありません。現行 adapter の
recover/local-onlyは non-closing binding を受理しないままです。これは今回の executor 修正とは分けて、残る制限として明示すべきであり、#2891 に無理に混ぜる必要はありません。推奨判断は「実装方針は採用し、上記の契約修正後に着手」です。 増やすべきなのは承認や防御の層ではなく、通常の呼び出し経路まで届く少量の配線と、途中失敗を正しく扱うテストです。
今回はソース・契約・コメントの静的照合と外部仕様の確認を行いました。リポジトリのテスト実行、コード変更、GitHub への投稿は行っていません。
## 結論:Issue 契約に対して `REQUEST_CHANGES` 相当です修正の方向は適切です。ただし、現在の #2891 は「認可 helper が受理できること」と「通常の cleanup 手順から、その入力を届けて完了できること」の間が抜けています。 大きな認可基盤や新しいハーネスを追加する必要はありません。実際の入力経路、CLOSED の扱い、途中失敗時の期待値を明確にする、小さな契約修正を勧めます。
確認時の #2891 は OPEN、コメントなしです。依存する #2878 の実装 PR #2896 はマージ済みなので、依存の完了待ちは不要です。コードは
fc34b8d6be5f6f110aaa7552bd2127fb590054dcを基準に確認しました。#2878 の発見元コメント、PR #2896 のレビューコメントと実装、#2508 の research fallback 契約、現在の executor・worker・Task Context adapter・関連テストを照合しています。以下は、確認できた実装上の事実と、そこから判断した Issue 契約の不足を分けたレビューです。
1. P1 — authority の入力口がなく、helper 修正だけでは通常実行に届かない
確認できた事実
cleanup_exec.py::main()が受け付けるのは、現在、次の引数です。そこから組み立てる
reqにも、non_closing_authorityは入りません。一方、run()と二つの認可関数は既に同じreqを受け渡しています。つまり、足りないのは主として helper 間の配線ではなく、CLI から request を作る入口です。さらに、実際の削除コマンドは、#2891 が変更を許可している orchestrator Skill ではなく、
.claude/skills/post-merge-cleanup-executor/SKILL.mdの Step 3 に記載されています。worker はこの executor Skill を読み、top-level orchestrator の手順は読み込まない契約です。worker の入力一覧も、現状はmerged_pr_numberとlinked_issue_numberの二つです。対して Issue の Current Validated Scope は、変更を「helper と呼び出し二箇所、単一テスト」に限定しています。In Scope には orchestrator の dispatch 追記があるものの、CLI 入力・worker 入力・executor コマンドの更新が明記されていません。
想定される失敗
テストが Python 側で直接、
を注入すれば認可は通る。しかし実際の worker は旧 CLI コマンドを実行し、authority が欠落して
linked_issue_mismatchになる――という、テストだけ成功する実装が成立してしまいます。最小修正案
既存 CLI に、例えば 任意の
--non-closing-authority-fileを一つ追加し、その JSON をreq["non_closing_authority"]に載せる方式を勧めます。これは提案する入口であり、現行実装に存在する引数ではありません。契約には、次の一本の経路を明記してください。
七キーの authority 形式を変える必要も、別の認可 schema を作る必要もありません。 Current Validated Scope を CLI の受け取りまで広げ、AC1 に「実際に案内する argv で production CLI を起動する」を加えるだけで、問題の中心を押さえられます。
なお、既存 orchestrator は、evaluator の
body_verdict == validのときだけ七キーを snapshot に添える手順になっています。この前提は維持し、単にdecision == nonclosing_requiredだけを見て未検証の結果を投影しないでください。本文 grammar を executor に再実装する必要はありません。2. P1 — CLOSED 拒否の意味が、継承する authority 契約と一致していない
「評価時 OPEN」と「実行時 OPEN」は別です
#2878 の adapter 実装は、明示的に次の設計です。
実際、七キーの authority には
issue_stateがありません。検査対象は decision、level、repo、issue/PR 番号、PR 本文 hash です。ところが #2891 の AC2 は、「対象 Issue が CLOSED」なら拒否としています。これは以下のどちらなのか判別できません。
level: CLOSEDを返した authority を拒否ここを曖昧にしたまま進めると、実装者によって API 呼び出し数と停止条件が変わります。
既存 research fallback とは、そのままでは衝突します
#2508 の research fallback は、
CLOSEDかつCOMPLETEDが許可条件です。また、closing relation に対象 Issue がある fast path は、追加の Issue fetch を行わない契約です。したがって、AC2 の「authority 欠落」「CLOSED」を全経路共通の入口で拒否すると、AC3 の「既存挙動不変」に反します。
推奨する整理
個人開発で余計な停止を増やさない方針なら、まずは #2878 と同じ評価時点の意味を継承するのが小さい変更です。
AC2 は、例えば次の意味に限定します。
ライブな CLOSED 拒否を本当に必要とするなら、それも実装できます。ただしその場合は、取得責務・失敗時の扱い・research fallback と情報を共有するかを明記すべきです。state を調べるためだけに、同じ Issue を重複取得する設計は避けたいところです。
また、CLOSED 後に fresh evaluator を実行すると A1/A2 の経路には戻れないため、当面の運用順序は cleanup 完了 → 必要な post-merge 証跡確認 → Issue close と明示するのが自然です。「先に close してから cleanup を再試行する」まで対応したとは報告しないでください。
新規経路の成立条件も一行追加したい
#2878 の non-closing binding は、closing relation が空の場合だけ評価され、別 Issue の closing node がある場合には fall through しません。#2891 も新規経路に限ってこの条件を明示すると、consumer 間の意味が揃います。既存 closing/research 経路全体を作り替える必要はありません。
3. P2 — Allowed Paths が、機能を使うための手順更新を妨げている
現行
post-merge-cleanup/SKILL.mdは、#2891 完了前の既知制限として、Refs-bound PR の削除を停止したままとする旨を記載しています。docs/dev/workflow.mdにも同じ制限が残っています。また、
tests/test_post_merge_cleanup_boundary.pyには、#2891 までの制限を背景とした assertion が残っています。ただし、ここは厳密に言うと、旧停止動作を直接実行して確認するテストではなく、Issue 番号や reason code などの文字列を確認するテストです。従って「実装を直すと必ずこのテストが落ちる」とまでは言えません。逆に、文字列を残しただけで green になっても、新しい受け渡しが正しい証拠にはなりません。推奨する変更範囲
元の三ファイルに加えて、同じ Outcome のための最小更新として、次を許可するのが妥当です。
.claude/skills/post-merge-cleanup-executor/SKILL.md.claude/agents/post-merge-cleanup-worker.mddocs/dev/workflow.mdtests/test_post_merge_cleanup_boundary.pyこれは別機能の追加ではありません。機能本体だけ許可し、それを使う手順の修正で Stop Conditions に当たる構造を解消する変更です。これだけのために別 Issue へ細分化することは勧めません。
一方、CI 定義の追加変更は不要です。現在の Python test plan は
scripts/agent-ops/tests/をディレクトリ単位で収集し、上記 boundary test も既に対象にしています。新テストを予定どおり配置すれば、収集対象になります。4. P2 — 「拒否時は削除なし」を、途中成功まで含めた保証にしてはいけない
通常 cleanup は、実装上は原子的な二操作ではありません
現行
run()には、次の回復経路があります。再認可で拒否された場合は、既に成功した
worktree_removeをactions_takenに残し、元のbranch_delete_failedを保持して終了します。これは既存コードが意図している、部分成功を隠さない挙動です。従って、例えば最初の認可後に PR 本文が変更され、再認可で hash が不一致になった場合、「authority 拒否だから削除ゼロ」と報告するのは誤りです。worktree は既に削除されています。
AC2 の修正案
拒否の期待値を、次の二つに分けてください。
actions_taken: []worktree_removeと元の失敗情報を保持ここで必要なのは新しい rollback 機構ではありません。既存の部分成功契約を壊さず、追加 authority も再認可まで届ける回帰テストです。
通常 lane と、最初から worktree が存在しない branch-only lane の二つだけでなく、同一 invocation 内で branch-only に移るケースを一つ入れる価値があります。
AC4 の discard 検証にも、入口の指定が必要です
cleanup_exec.pyの CLI は discard lane を公開していません。コード上、discard はmaterialize_cleanup_contract.pyの--check/--consume側から呼ばれる設計です。従って「AC1〜AC4 を cleanup_exec の subprocess で確認」とだけ書いても、AC4 の到達経路は定まりません。ここは、authority を含む request に対する小さな関数テストと、既存 discard の production entrypoint を通す subprocess 回帰の役割を分けるのが現実的です。テストのために新しい discard CLI や実行器を追加する必要はありません。
外部仕様・実装と照合した改善ポイント
GitHub の close と、cleanup の関連付けは分離したままでよい
GitHub 公式仕様の closing keyword に
Refsは含まれず、commit message の closing keyword からも Issue が閉じられます。従って、cleanup を通すためにRefsをClosesに変更したり、手動の closing link を代用品にしたりする案は不適切です。今回の非 closing authority 追加は、この意味でも正しい方向です。[GitHub Docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue?utm_source=chatgpt.com)ただし、「PR 本文が Refs でも別経路で auto-close される」問題は、PR #2896 の修正対象として既に扱われています。#2891 の blocker として、同じ pre-merge close 検査を executor に重複実装することは勧めません。
PR 本文を取得する新しい API 経路は不要
GitHub CLI は
body、closingIssuesReferences、numberなどを JSON 出力対象に持ち、CLI 本体の query builder もこれらを扱っています。GitHub CLIそして、このリポジトリの
_pr_state()は 既にbodyを取得しています。その値を hash 計算に使えばよく、本文専用の新しい GraphQL/REST 呼び出しは不要です。実装時は、JSON から取り出した文字列の UTF-8 bytes をそのまま使い、
.strip()や末尾改行の追加を挟まない形にしてください。既存 adapter と同じ計算に合わせ、末尾改行・CRLF を小さな fixture で押さえるだけで十分です。残すべきなのは、データ消失に直結する既存の検査
Git の
worktree removeは通常、変更・未追跡ファイルのない worktree を対象とし、branch -dとbranch -Dも意味が異なります。これらを一律に force へ倒す「簡略化」は避けるべきです。Git一方、本件に署名付き attestation、期限管理台帳、close actor の追跡、追加の人間確認を持ち込む必要は感じません。既存の merged PR・repo・branch・OID・clean 判定を維持し、今回足すのは関連付けの一経路だけにするのが、目的に合っています。
exit 77は pytest の標準動作ではないIssue は uv/pytest 不在を「exit 77 SKIP」としていますが、pytest の標準 exit code に 77 はありません。文書に書くだけでは、その終了コードにはなりません。 [pytest ドキュメント](https://docs.pytest.org/en/stable/reference/exit-codes.html?utm_source=chatgpt.com)
専用ハーネスを増やすより、依存不足を environment blocked として記録するか、既存の実行手段で変換する責務を明記する程度でよいです。重要なのは番号そのものではなく、未実行を PASS にしないことです。
この Issue で固定するとよい受け入れ条件
私なら、実装開始前に AC を次の内容へ整理します。
actions_takenを失わない不正な型の fixture は、
levelの list/object、番号の bool/文字列など、既存 #2878 が既に対処した境界を小さく再利用すれば足ります。新しい一般化された validation framework は不要です。最後に、この修正だけで、Refs PR のあらゆる復旧経路が解禁されるわけではありません。現行 adapter の
recover/local-onlyは non-closing binding を受理しないままです。これは今回の executor 修正とは分けて、残る制限として明示すべきであり、#2891 に無理に混ぜる必要はありません。推奨判断は「実装方針は採用し、上記の契約修正後に着手」です。 増やすべきなのは承認や防御の層ではなく、通常の呼び出し経路まで届く少量の配線と、途中失敗を正しく扱うテストです。
今回はソース・契約・コメントの静的照合と外部仕様の確認を行いました。リポジトリのテスト実行、コード変更、GitHub への投稿は行っていません。
squne121 commentedon Oct 4, 2026
確認した live state では、#2891 は OPEN、指定コメントは OWNER の
REQUEST_CHANGES相当、依存 PR #2896 は MERGED、確認時 main はfc34b8d6be5f6f110aaa7552bd2127fb590054dcです。currentissue-refinement-loopは既定max_iterations=3・iteration ごとの承認不要で、Step 2 は background 起動後の completion join が必須です。推奨は、指定コメントを
operator_asserted_human_contextとして canonicalwith_human_contextlane に投入し、#2891 の実装には進まず、契約を「production CLI→worker→executor までの authority 配線」「CLOSED semantics」「途中成功を含む回帰テスト」まで修正して fresh review で approve まで持っていくことです。recover/local-onlyの non-closing 未対応は #2891 に混ぜず、fresh dedupe 後に未追跡なら再発防止 follow-up の有力候補です。そのまま貼り付ける prompt です。
repo
squne121/loop-protocolの Issue #2891 に対して、current repository の.claude/skills/issue-refinement-loop/SKILL.mdを正本として issue refinement を最後まで実行してください。対象:
実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 (comment)
author_associationから human origin を推測するのではなく、currentissue-refinement-loopの Accepted Trust Model に従いoperator_asserted_human_context/preflight.run.with_human_contextlane を使用すること。到達目標
指定 OWNER コメントの
REQUEST_CHANGESを #2891 の Issue contract に正しく反映し、currentissue-refinement-loopの canonical review/refinement loop を bounded に完遂してください。この invocation は Issue refinement のみです。
impl-review-loopを起動しない。approvedになったら current Skill の termination contract に従って終了する。approvedを implementation 開始許可へ読み替えない。最初に必ず fresh 確認すること
過去のコメント・この prompt に記載された SHA や契約を current state の代用にしない。
main/origin/mainの fresh HEAD.claude/skills/issue-refinement-loop/SKILL.mdreferences/**.claude/agents/**のうち実際に起動する SubAgent の current contractCLAUDE.md参考として、この prompt 作成時点では:
fc34b8d6be5f6f110aaa7552bd2127fb590054dcだった。ただし必ず fresh state を優先すること。
承認済みの作業
以下の通常・非破壊的な refinement 作業について、iteration ごとの人間承認は不要です。必要なら自律的に実行してください。
issue-refinement-loopの canonical preflight / planner / investigation / review / rewrite / readiness / terminationwith_human_contextlane で consume することissue-editorによる Issue contract rewriteこの承認は Claude Code の permission mode を変更する指示ではない。
bypassPermissions/--dangerously-skip-permissions等は要求しない。current Skill の
max_iterationsが変更されていなければ既定の 3 を用い、needs-fixは上限まで自動継続すること。通常の
needs-fix、修正可能な readiness failure、stale evidence は人間確認のために停止せず、current canonical route に従って修正・再検証すること。canonical entry を守ること
anchor URL を直接 wrapper に適当に渡すのではなく、current
issue-refinement-loopの command registry / canonical executor を使うこと。current contract が現在も同じなら、最初の route は概念的には:
preflight.run.with_human_context→ 必要なら
contract_update.run.with_human_context→ fresh preflight / review
→ Step 4 rewrite
→ fresh review
→ termination
である。
run_refinement_preflight.pyを canonical entry gate を迂回して直接実行しないこと。planner / deterministic checker / route producer が authority を持つ判断を prose で再実装しないこと。
SubAgent の扱い
SubAgent は current repository contract に従って使用してください。
特に:
investigation_policy.required == trueとした場合はcodebase-investigatorを使う。issue-editorを使う。web-researcherroute を使う。issue-reviewerSubAgent を勝手に復活させない。current Skill が root-owned review pipeline を authority としているならそれに従う。重要:
SubAgent を dispatch しただけで完了扱いにしない。
各 SubAgent について terminal completion と final result を必ず取得・検証してから downstream step へ進むこと。
独立な read-only investigation が複数あり current contract が許す場合は並列化してよいが、依存関係があるものは順序を守る。
SubAgent へは最低限:
を明示し、親 context の暗黙情報へ依存させないこと。
canonical planner が SubAgent dispatch を明示的に非適用とする route である場合、SubAgent を使うこと自体を目的に SSOT を迂回しない。その場合は final report に理由を記録すること。
Step 2 の completion join
current
issue-refinement-loopが引き続き要求している場合、root_review_pipeline.produceは明示的 background 実行し、background task の terminal completion notification と実結果を join するまで Step 2 完了扱いにしない。background launch 成功だけで downstream routing へ進まない。
canonical_step2_routeが routing authority なら、その値をそのまま consume し、verdict 等から独自再計算しない。指定 OWNER コメントで解決すべき主要事項
コメントの prose を盲目的に転載するのではなく、fresh repository evidence と照合したうえで、少なくとも以下の defect class が Issue contract から消えていることを確認してください。
1. production input path を end-to-end で契約化する
現行 #2891 は helper が
non_closing_authorityを受理する話に偏っており、通常 cleanup invocation がその authority を届ける production input path が不足している。fresh code を確認し、最小の具体的な経路を Issue contract に固定すること。
期待する end-to-end chain は概念的に:
fresh evaluator の valid authority
→ top-level post-merge orchestrator / snapshot
→ worker input
→ executor Skill の production command
→
cleanup_exec.pyCLI entry→ request object
→ normal cleanup authorization
→ branch-only authorization
→ 同一 invocation 内の branch-only re-authorization
である。
target comment では optional な
--non-closing-authority-fileのような file-based input が最小案として提案されているが、flag 名を先に真実として固定しない。current code / established conventions を調べ、既存 pattern と最も整合する小さい入口を選び、その exact production path を Issue contract に明記すること。
新しい汎用 authorization framework、schema、wrapper、approval layer を作る方向へ拡張しない。
2. CLOSED semantics を曖昧にしない
#2878から継承する七キー authority が「evaluator 実行時の A1/A2」を表し、live execution-timeissue_stateを含まない現行契約であるか fresh 確認する。それが current contract のままなら、#2891 の新しい non-closing path は:
で認可されなかった後の追加 path とする。
新しい non-closing path では:
decision == nonclosing_requiredなど current 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 authority contract を検証する。
level: CLOSED/ A3 等は新規 non-closing path では拒否する。一方で cleanup 実行時に live Issue state を再 fetch して CLOSED を拒否する新責務は、current repository evidence が必要性を示さない限り追加しない。
既存 research fallback の CLOSED/COMPLETED semantics を壊さない。
closing relation fast path / research fallback の既存優先順位を保持し、authority 欠落を入口全体の拒否条件にして既存 path を退行させない。
3. Allowed Paths を実際の production wiring と一致させる
target comment が指摘した以下を fresh repository で検証し、同じ Outcome のために必要なら #2891 の Allowed Paths / In Scope / Current Validated Scope を拡張する。
有力候補:
scripts/agent-ops/cleanup_exec.pyscripts/agent-ops/tests/test_cleanup_exec_non_closing_authority.py.claude/skills/post-merge-cleanup/SKILL.md.claude/skills/post-merge-cleanup-executor/SKILL.md.claude/agents/post-merge-cleanup-worker.mddocs/dev/workflow.mdtests/test_post_merge_cleanup_boundary.pypath が現在 rename/move 済みなら current canonical path を使う。
「実装本体だけ Allowed にして、実際にその input を渡す worker/executor/doc/test の更新が Stop Condition に引っ掛かる」契約を残さない。
ただし unrelated directory や別 architecture layer まで広げない。
4. runtime / regression contract を false-green にしない
テストが Python request に直接
non_closing_authorityを注入するだけで AC1 を満たしたことにしない。production CLI / worker / executor が実際に案内する input route を subprocess 等で通す regression を要求すること。
少なくとも意味として以下を区別する:
A. 最初の destructive operation 前の authorization failure
actions_takenは空B. initial auth success 後:
の場合
worktree_removeを隠さないrollback mechanism を新設しない。既存 partial-success contract を保持する。
5. discard lane を実入口で検証する
discard lane を #2891 の認可対象にしない。
cleanup_exec.pyに discard 用の偽 CLI をテスト目的で追加しない。fresh current code を確認し、discard の production entrypoint が
materialize_cleanup_contract.py等の別 surface なら:verify_discard_authorizationの semantics が変わらないことを小さい unit/function boundary で確認のように役割を分ける。
AC4 の verification command が実際に到達不能な entrypoint を検証したことにしない。
6. docs / known limitation を更新する
#2891 完了前を前提にした「Refs-bound PR cleanup は停止」の文言が current:
等に残っていれば、今回の Outcome に合わせて修正対象へ含める。
一方、今回の修正だけで全 recovery path が解禁されたとは書かない。
特に fresh code でも:
recoverlocal-onlyが non-closing binding を受理しないなら、それは 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 の Out of Scope / Remaining limitation として明記する。
#2891 に無理に実装を混ぜない。
stale dependency / stale source の整理
#2891 の本文には、古い main SHA や「Depends on #2878 merge」前提が残っている可能性がある。
fresh state で #2896 / #2878 dependency が既に満たされているなら:
ただし native dependency / body dependency の扱いは current dependency materialization SSOT に従う。
望ましい contract の性質
最終 Issue body は少なくとも以下を満たすこと:
review / rewrite loop
Issue を一度編集して終了しない。
を current Skill の authority に従って完遂すること。
修正後の review は必ず fresh Issue body SHA / fresh main HEAD を対象にする。
過去 iteration の approve/needs-fix artifact を再利用しない。
再発防止 follow-up Issue
refinement の途中または approve 後に、今回とは別 Outcome だが再発しやすい問題を確認した場合は、既存 Issue を fresh 検索してください。
特に target comment で明示された:
recover/local-onlyでは依然受理されないという残存制限は follow-up 候補として評価すること。
ただし:
未追跡で、同じ failure が通常 workflow で再発する蓋然性が高い場合は、current repository convention に従って GitHub Issue を起票してよい。これはこの invocation で明示的に承認する。
新 Issue には最低限:
を含める。
current
issue-refinement-loopの Step 4.5 follow-up materialization contract が applicable なら、それを優先する。停止境界
以下は承認不要の通常 iteration と混同しない。
停止 / escalation してよいのは current canonical contract が要求する場合のみ。例:
human_judgment_required通常の review finding、deterministic repair、readiness needs-fix、修正可能な test/contract failureを人間確認の理由にしない。
他 task の dirty worktree / foreign branch / unrelated changes は変更・削除しない。
最終報告
終了時には簡潔に以下を報告すること。
GitHub 上の canonical termination comment / marker は current
issue-refinement-loopの規定どおり controlled publisher から出すこと。この prompt では、指定コメントの技術提案を採用しつつ、flag 名など実装詳細は fresh code を見て最小案に確定させるようにしています。また、refinement 完了から実装開始へ勝手に遷移しない点も current Skill に合わせて固定しています。
squne121 commentedon Oct 4, 2026
issue-refinement-loop 終了報告: approved
fc34b8d6be5f6f110aaa7552bd2127fb590054dc/ 承認本文 SHA-256ebd96d779da21dba6af382472256016e24b31b7479404e0273f3a628945a57e1--non-closing-authority-file)を orchestrator → worker → executor Skill →cleanup_exec.pyCLI → 初回認可 / branch-only 認可 / 同一 invocation 内再認可まで契約化。CLOSED は 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の評価時点 semantics を継承し、live Issue state の再取得は追加しない。Allowed Paths を worker / executor Skill / workflow docs / boundary test / runtime smoke fixture へ拡張。初回認可前の拒否と、途中成功(worktree 削除済み・再認可拒否)を AC で区別。discard lane は既存 production entrypoint で検証。旧#2891 まで停止文言を更新対象に含め、recover/local-only未対応を Out of Scope として明記。stale な依存待ち記述を整理(実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 / PR feat: PR の Closes/Refs 選択と post-merge OPEN close gate を単一の reference authority evaluator で整合する (#2878) #2896 は完了済み)。effective_verdict: approve。task-context:recover-local-only:non-closing-authority:v1。recover / local-only の non-closing binding。既存 owner Issue なし)approvedは実装開始の承認ではない。squne121 commentedon Oct 4, 2026
確認した範囲では、現在の
mainはfc34b8d6…、#2891 は OPEN で refinement はapproved済み、#2891 向けの open PR はまだ見当たりません。既存 follow-up #2910 はrecover / local-onlyの non-closing binding を所有しています。また、添付ログでは refinement 終了時の Task Context signal がFACT_TASK_IDENTITY_CONFLICTで適用されず、ambient Task Context が#2147483646を指したままだったことが確認できます。貼り付けたテキスト(1) 貼り付けたテキスト(1)Task Context の再発調査では、#2827(ordinary prompt の auto-rebind)は CLOSED、#2826(
refinement_approvedconflict 分類)は CLOSED、#2817(post-merge recovery)は CLOSED、一方 #2835(one-primary-Issue invariant の signal 間不整合)は OPEN です。したがって、今回の実装中に同じ auto-rebind failure を再現した場合、まず #2835 等との重複を判定し、別 failure class の場合だけ新規 Issue を作らせるのが適切です。以下を、現在 auto mode で起動済みの fresh interactive Claude Code にそのまま貼り付けてください。
repo
squne121/loop-protocolの Issue #2891 を対象に、current repository の.claude/skills/impl-review-loop/SKILL.mdとその currentsteps/**を正本として、実装 → 検証 → PR review → fix → 再検証の canonical loop を、人間が merge 判断できる直前まで自律的に完遂してください。対象:
実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 (comment)
実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 (comment)
squne121/loop-protocolこの invocation の明示的 target は Issue #2891 です。
impl-review-loopの入力・LOOP_STATE・worktree/branch/PR identity・SubAgent task では、必ずissue_number: 2891を明示してください。重要: ambient Task Context が stale である
現在の interactive session では Task Context が自動更新されず、UI 上の current Task が
#2147483646のまま残っている可能性があります。この ambient Task Context を #2891 の target authority として使用しないでください。
impl-review-loopcontract を正本とする。/task 2891を blind recovery として実行しない。現在の repository contract が明示的に要求し、かつ ownership が整合すると fresh evidence で確認できた場合だけ canonical recovery を使う。FACT_TASK_IDENTITY_CONFLICTやtask_context_signal_not_appliedが telemetry / advisory に過ぎない current route では、それを implementation loop の独自 hard blocker に格上げしない。最初に Task Context の current state と origin identity を repository-native な read-only diagnostic で確認してください。自動 rebind が本当に起きていない場合は、再現 evidence を保存してください。ただし Task Context の調査だけで #2891 の実装を放棄しないでください。
Task Context 周辺で follow-up が必要になった場合は、最低限以下を fresh に確認して dedupe してください。
refinement_approvedのFACT_TASK_IDENTITY_CONFLICT分類refinement_approved/implementation_pr_observedの one-primary-Issue invariantnon_closing_authoritybinding既存 owner Issue が同じ failure class を所有している場合は新規 Issue を作らない。必要なら fresh reproduction evidence を既存 Issue に関連付ける。
current main で再現し、上記および他の既存 Issue が所有していない別 failure class なら、後述の条件で follow-up Issue を起票してください。
到達目標
current #2891 contract を満たす production implementation を完成させ、current
impl-review-loopの termination contract に従って:inspect → canonical intake → implement → verify → Draft PR create/update → PR review → fix → re-test → fresh-head re-review → required CI/mergeability確認 → merge直前で停止まで進めてください。
次で止めないこと:
最初に必ず fresh 取得すること
過去 prompt、添付ログ、refinement 時の SHA を current state の代用にしないでください。
最初に以下を fresh に確認してください。
main/origin/mainの current HEAD#issuecomment-5975330732CLAUDE.md.claude/skills/impl-review-loop/SKILL.mdsteps/**.claude/skills/implement-issue/SKILL.md.claude/skills/open-pr/SKILL.md.claude/skills/pr-review-judge/SKILL.md.claude/agents/implementation-worker.md.claude/agents/test-runner.md.claude/agents/pr-reviewer.md参考値として prompt 作成時点では:
fc34b8d6be5f6f110aaa7552bd2127fb590054dcebd96d779da21dba6af382472256016e24b31b7479404e0273f3a628945a57e1ですが、必ず fresh state を優先してください。
canonical
impl-review-loopentry を使うimpl-review-loopの current Root-Owned Synchronous Entry Transition を守ってください。current contract が同じなら、root/main thread が同一 continuous invocation 内で:
issue-contract-reviewまでを連続して行ってください。
古い contract snapshot、termination comment、body SHA、artifact、invocation id 等を Step 1 authorization token として再利用しないでください。
planner / deterministic router / landing disposition producer が authority を持つ判断を、自然言語で再実装しないでください。
existing PR / worktree の扱い
Evidence-Based Landing Disposition を 新 worktree / worker / PR 作成より先に current contract どおり実行してください。
prompt 作成時に open PR が無かったことを、新規 PR 作成の根拠にはしないでください。fresh search が authority です。
明示的に承認する通常作業
以下は、この invocation について人間の iteration ごとの追加承認なしで実行してよいです。
git fetch等の非破壊的な live state 更新impl-review-loopが要求する canonical intake / preflightimplementation-workerの起動test-runnerの起動pr-reviewer/pr-review-judgeの起動open-prSkill による Draft PR 作成この承認は Claude Code の permission bypass を意味しません。
以下を要求・使用しないこと:
bypassPermissions--dangerously-skip-permissionsrm -rf等による workflow の迂回SubAgent completion barrier
SubAgent は積極的に使用してください。
ただし dispatch しただけで downstream step へ進まないこと。
各 SubAgent ごとに:
を必須にしてください。
特に:
implementation-workerの terminal completion とIMPLEMENT_RESULT_V1test-runnerの terminal completion と current-head verification resultpr-reviewerの terminal completion と current-head verdictを取得するまで、それぞれ次の Step に進まないこと。
SubAgent の親会話の暗黙 context に依存させないでください。
各 delegation message に最低限:
を明示してください。
#2891 実装で特に落とさない点
live Issue contract を最優先しつつ、refinement termination comment の semantic warning も読んでください。
少なくとも次を実装・review 時に明示的に確認してください。
non_closing_authority_fileは orchestrator → worker の Delegation message / Materialization rule に path だけを渡す。cleanup_execargv 全体を組み立てて worker に渡す別経路を作らない。.claude/skills/post-merge-cleanup-executor/SKILL.mdの production command block とcleanup_exec.pyargparse の--non-closing-authority-fileが drift していないことを機械的に確認する。
reqへ直接 authority を注入しただけで AC1 を満たした扱いにしない。cleanup executor 側 twin の
authority.repoは、current contract に従い trusted repo identity /repo_slugと照合する。closing fast path / 実装: cleanup_exec.py が research issue(closing keyword不使用)のPRに対してlinked_issue_mismatchで恒常的にworktree/branch cleanupを拒否する問題を修正する #2508 research fallback を壊さない。
authority は evaluator の
body_verdict == validのときだけ materialize する current contract を維持する。decision == nonclosing_requiredだけを見て未検証 evaluator result を投影しない。initial authorization rejection と same-invocation partial success を混同しない。
actions_taken: []worktree_removeを保持、branch を残し、元の failure を保持discard lane を 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 の authority で拡張しない。
recover/local-onlyの non-closing Task Context binding は 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 へ混ぜない。runtime smoke は Issue が要求する既存 runner / fixture contract に従う。
-新しい一般化 harness / approval layer を作らない。
実装・検証
Step 1 は current
implementation-workerを使ってください。Allowed Paths 外の編集は禁止。
worker 完了後、current #2891 Verification Commands と current Skill が要求する品質 gate を実行してください。
test failure は可能な限り root cause を直して再実行してください。
test を削除・弱体化して green にしないでください。
既存 test の意味を別 semantics に変えて見かけ上 PASS にしないでください。
Issue の runtime AC は current HEAD に対して実行し、PR 本文の Runtime Verification Evidence に current-head identity と結果を記録してください。
PR
新規 PR が必要な場合は current
open-prSkill を使用し、1 Issue = 1 PR を維持してください。open-pr/ reference-policy evaluator に決めさせる。Closes/Refsを prompt の固定文字列で決め打ちしない。PR review / fix loop
Step 2 verification の current-head gate を通過した後、current
pr-reviewer/pr-review-judgeで PR review を実行してください。reviewer を dispatch しただけで終わらず terminal completion を取得してください。
control-plane は reviewer 自己申告の mergeability を信用せず、current
impl-review-loop契約どおり live PR mergeability / required CI を直接取得してください。route は current
route_loop_verdict_v2()を authority とすること。REQUEST_CHANGES→ blockers を exactfix_deltaとしてimplementation-workerに返すBEHIND→ current router が選ぶ update_branch route → verification + review 再実行APPROVE単独で終了しないapprovedとするcurrent Skill の
max_iterationsが 3 のままなら 3 を使用してください。REQUEST_CHANGES / deterministic fix / stale HEAD は iteration 上限内で自動継続してください。
Task Context auto-rebind failure の再発防止
この invocation 中に、普通の #2891 指定 prompt であるにもかかわらず ACTIVE Task が #2891 へ追従せず、別 Task identity が残る現象を current main で再現した場合:
新 Issue には最低限:
を含めてください。
単なる将来 hardening や追加 approval layer は起票しないでください。
同様に、#2891 実装中に別の反復可能な defect を発見した場合も、既存 Issue を fresh dedupe した上で、#2891 と別 Outcome で通常 workflow に再発する具体的 failure class のときだけ follow-up Issue を作成してください。
停止境界
次だけを genuine stop / escalation 候補にしてください。
human_judgment_required次は停止理由にしないでください。
-修正可能な CI failure
human_review_required: true自己申告だけrefinement_approvedTask Context signal の conflict だけ(current canonical implementation route が hard blocker と定義していない限り)merge 境界
merge / auto-merge は実行しないでください。
PR が current-head で:
状態まで進め、人間が merge を判断できる直前で停止してください。
post-merge cleanup は実行しないでください。まだ merge していないためです。
最終報告
最後に簡潔に、しかし evidence を伴って次を報告してください。
-既存 Issue に evidence を追加した場合はその URL
現在 auto mode で既に起動しているこの interactive session をそのまま継続し、通常作業について途中承認を求めず進めてください。
この prompt では Task Context の不整合を無視するのではなく、明示 target #2891 と Task Context telemetry を分離しつつ、再現すれば既存の #2827/#2826/#2835/#2817 と dedupe するようにしています。これなら stale context が implementation target を乗っ取ることも、同じ問題の Issue を乱立させることも避けられます。
squne121 commentedon Oct 4, 2026
implement-issue: 実装完了
.claude/worktrees/issue-2891-cleanup-exec-linked-issue-closing-relatiworktree-issue-2891-cleanup-exec-linked-issue-closing-relati466f64b4036ad61c62b234471cf94ad295c4fb24squne121 commentedon Oct 4, 2026
impl-review-loop: 完了 (2026-10-04T07:43:26Z)
feat: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closi…