Skip to content

実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR reference と Issue close gate を別の判断として整合し、post-merge live evidence の未取得時に Issue を閉じず、かつ merge 後の Task Context cleanup binding が対象 Issue を見失わない"
change_kind: workflow

Parent Issue

なし(単独 follow-up。#2842 は発見元であって parent ではない)

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

なし(親 Issue なし)。#2842 の AC6/AC7 live smoke 実施と close 判断は #2842 側に残る。

Background

#2842 は AC6/AC7 に「PR SHA 隔離実 Git repo での pre-merge evidence」と、merge 後に実際の canonical main root / default branch・linked worktree 0 件で取得する live production subprocess positive/negative evidence の両方を要求する。#2861 は Draft / OPEN であり、human decision により Refs #2842 が正しい。merge 前に Closes #2842 へ復元すると auto-close が live evidence に先行するため禁止。

根本原因は「linked Issue 特定」と「merge 時に close してよいか」を Closes だけで兼用したこと。fresh main(f7a2cff5)で確認した現状の断絶は次の 4 点。

  1. producer / validator / reviewer: open_pr.py は Issue state のみで OPEN→Closes / CLOSED→Refs を既定とし、validator(LP057)は Refs も受けるが、pr-review-judge は Closes 不在を一律 REQUEST_CHANGES とする。
  2. post-merge identity: task_context_workflow_signal.py::_merged_evidence() は closingIssuesReferences.nodes がちょうど 1 件で対象 Issue と一致することを要求し、0 件は RELATION_ISSUE_MISMATCH。post-merge-cleanup/SKILL.md の決定表ではこれは「停止(local-only なし、削除なし)」で、Refs PR は merge 後 cleanup に入れない。open_pr.py::classify_closing_issue_relation() も 0 件を NO_LINK とするため implementation_pr_observed も発行されない。
  3. close gate: 実装 Issue を evidence 確認後に close する production consumer は存在しない(parent_issue_close は frozen wire で常に false、gh issue close は orchestrator / 人間の明示操作)。Refs-bound Issue は GitHub semantics により merge で auto-close されず OPEN のまま残るため、必要なのは「OPEN を保つ判断の authority」と「閉じてよい条件の文書化」であり、新たな自動 close 実行器ではない。
  4. impl-review-loop: test_handoff_pr_hygiene_regression.py に「Refs-only は Closes 欠落で failure」という legacy 前提が残り、step-5-feedback-and-termination.md は ensure_closing_keyword を無条件の body-only 自動修復とする。reviewer だけ Refs-aware にしても、隣接 repair が Refs を Closes へ戻す。

Reference authority model(本 Issue で固定する唯一の判断規則)

判断は facts を入力とする 1 つの pure evaluator(validate_pr_body.py 内)に集約する。evaluator は GitHub を取得せず、caller が渡す facts(PR 本文、linked Issue の state、linked Issue 本文、A1 の comment 事実)だけから decision(closing_required / nonclosing_required / fail_closed)・level(A1 / A2 / A3 / CLOSED)・reason_code を返す。evaluator は CLI entrypoint(validate_pr_body.py --evaluate-reference-policy、出力は 1 つの JSON object)も持ち、producer(open_pr.py)、pr-review-judge Step 1、impl-review-loop step-5 の repair 判定は、いずれも facts を gh で fresh 取得してこの entrypoint を呼び、その結果だけを消費する。prose / フリーテキストのキーワードからは推測しない。--reference-facts-file を渡さない既存 caller(update_pr.py 経由の body 更新を含む)は従来の LP057(番号一致の検証)のまま動作し、本 Issue はそれを変更しない。policy 判定を要求する caller は facts を必ず供給し、facts の欠落・不正は fail_closed とする。

CLI contract(既存の必須引数を再利用し、新 schema / 新 CLI は作らない):

  • 入力の分担: PR 本文は既存 --body-file(evaluator は bytes を読み、UTF-8 として解釈する。改行変換・正規化なし)、対象 Issue 番号は既存 --linked-issue、対象 Issue 本文は既存 --linked-issue-body-file、残りの facts は新規 --reference-facts-file(JSON)で渡す。
  • --reference-facts-file 単独(--evaluate-reference-policy なし)は既存 lint の LP057 を policy 判定へ切り替える(出力は従来の loop_body_lint/v1 のまま)。--evaluate-reference-policy は --reference-facts-file と --linked-issue-body-file を必須とし、lint を実行せず evaluator 結果の JSON object だけを stdout に出す。いずれかが欠けた場合は fail_closed(facts_invalid)の JSON を出す。lint mode(--reference-facts-file あり・--evaluate-reference-policy なし)で --linked-issue-body-file が無い場合も同じく fail_closed(facts_invalid)とし、LP057 エラーにする(A1 のみで確定できる場合でも本文なしは受け付けない)。--body-file が読めない場合のみ既存どおり stderr + exit 2。
  • exit code: evaluator mode は JSON を出力できた場合は decision によらず exit 0(呼び出し側は JSON の decision を読む。exit code で decision を伝えない)。
  • facts JSON(--reference-facts-file)の exact keys(これ以外の key・型違い・欠落は fail_closed / facts_invalid): repo(<owner>/<repo> 文字列)、issue_state(OPEN または CLOSED)、pr_number(正の整数。PR 作成前の評価では null を許す)、decision_comment(A1 の fresh 取得結果。取得していなければ null、あれば url / id(整数)/ issue_url(comment の issue API URL)/ author_association / body の 5 key を持つ object)。facts.repo と --linked-issue は対象 Issue の identity を決め、PR 本文・comment URL との一致検証に使う。updated_at は facts に含めず、authority にも freshness にも使わない(freshness は caller が評価直前に fresh 取得する責務と、merge 直前の再評価で担保する)。
  • evaluator output の exact keys と enum: decision(closing_required / nonclosing_required / fail_closed)、level(A1 / A2 / A3 / CLOSED / null。fail_closed は null)、reason_code(issue_closed / a1_explicit_decision / a1_decision_invalid / a1_decision_ambiguous / a2_contract_deferred / a3_close_ready / runtime_applicability_unresolved / facts_invalid のいずれか)、repo、issue_number、pr_number(facts の値の echo)、pr_body_sha256(evaluator が実際に評価した --body-file の bytes から算出した小文字 hex。別経路の文字列から算出しない)、effective_kind(closing / non-closing / notes-only / none)、body_verdict(valid / repair / block)、body_reason(ok / closing_for_other / closing_forbidden / closing_missing / reference_missing / not_evaluated)。fail_closed のとき body_verdict は block、body_reason は not_evaluated。

reference の grammar(evaluator が唯一の定義元。GitHub の closing 判定を over-approximate する保守的な定義):

  • closing の検出は PR 本文の生 text 全体(code fence・inline code・引用行を除外しない)を対象にする。GitHub の closing keyword 全て(close / closes / closed / fix / fixes / fixed / resolve / resolves / resolved、大文字小文字無視、keyword の後に任意の : と空白)の直後が actual issue target grammar に入る場合だけを closing reference の候補とする。target grammar は ASCII 数字列 [0-9]+(文字列として比較。#21010 と #2101 の prefix collision を起こさない)を持つ #N、<owner>/<repo>#N、https://github.com/<owner>/<repo>/issues/N の 3 形のみで、GitHub 公式の linking 仕様(keyword の直後に #ISSUE-NUMBER / OWNER/REPO#ISSUE-NUMBER、issue URL。keyword と target の間の任意の : と空白)に合わせる。実装時に GitHub 公式 docs を fresh に確認して grammar を固定する。候補の target が対象 Issue(同一 repository・同一番号)なら「closing for target」、別 Issue・別 repository なら「closing for other」とする。keyword の直後が target grammar に入らない場合(fixes the typo、resolved by the earlier change、closes the loop 等の通常 prose)は reference ではなく単に無視し、fail_closed にしない(fail_closed は facts / authority 側の不正に限る)。code fence や引用内の keyword も同様に検出する(GitHub が link するか未検証のため、検出側に倒す)。
  • non-closing は、code fence・inline code・引用行を除いた text 中の Refs #N(ASCII 数字。#21010 と #2101 の prefix collision を起こさない完全一致)を対象 Issue への参照として数える。
  • effective kind は 1 つに決める: 対象への closing keyword が 1 つでもあれば closing(Closes #N と Refs #N の併存も closing)、無ければ対象への Refs があれば non-closing、どちらも無ければ none。同種別の重複参照は許容する。closing for other が 1 つでもあれば常に reject する(番号違い)。Related issue: の Notes 欄だけの参照(既存 validate_pr_body.py::_extract_notes_related_issue を再利用して値を取り出し、番号が対象 Issue と文字列として完全一致する場合)は notes-only、Notes の番号が対象と異なる場合や参照が全く無い場合は none として扱う。
  • 判定の組合せ(body_verdict / body_reason の写像。closing for other は常に block / closing_for_other): closing_required では closing が valid / ok、non-closing(根拠のない Refs-only)は repair / closing_missing(Closes へ。repair の可否は caller が決め、evaluator は auto repair を行わない)、none と notes-only は block / reference_missing。closing_required の valid 判定が数える closing は code fence・引用行の外にある closing for target に限る(fence / 引用内にしか対象への closing keyword が無い本文は GitHub が link しない可能性があるため repair / closing_missing。この場合も effective_kind は検出(raw)基準のまま closing で、fence 外の Refs #N の有無や参照なしでも effective_kind / body_verdict / body_reason は変わらない。AC2 の fixture はこの exact output を固定する。nonclosing_required と closing for other の検出は従来どおり fence / 引用内も数える)。nonclosing_required では non-closing が valid / ok、closing(併存を含む)は block / closing_forbidden、none / notes-only は block / reference_missing。CLOSED の linked Issue(level: CLOSED。authority 評価をしない)は専用の写像に従う: non-closing(対象への Refs)と notes-only(Notes の Related issue: が対象番号と一致)は valid / ok、対象への closing keyword(fence / 引用内を含む)は block / closing_forbidden、none(参照なし、または Notes の番号違い)は block / reference_missing(現行 LP057 が Notes のみを許容する挙動を保つ)。

authority(OPEN の linked Issue。上から評価し最初に確定した結果を採る。total な優先順位):

順 条件 decision
0 linked Issue が CLOSED nonclosing_required(level: CLOSED。authority 評価なし)
1 A1 present かつ valid nonclosing_required(level: A1。Runtime Verification Applicability section の状態に依存しない)
2 A1 present かつ invalid fail_closed(A2 / A3 へ降格しない)
3 A1 なし、A2 成立 nonclosing_required(level: A2)
4 A1 なし、A2 不成立、A3 成立 closing_required(level: A3)
5 上記以外(Issue state 取得不能、Runtime Verification Applicability section の欠落・重複・解釈不能、facts 不正) fail_closed
  • A1 explicit reference decision: PR 本文(raw text 全体。code fence・引用を除外しない)の行頭が Reference-Decision: の行を数える。0 行なら A1 なし。2 行以上は URL が同一でも A1 present かつ invalid(a1_decision_ambiguous、fail_closed。A2 / A3 へ降格しない)。ちょうど 1 行の場合、その値は canonical 形 https://github.com/<owner>/<repo>/issues/<N>#issuecomment-<id> でなければならない(形が違う行も A1 invalid)。A1 valid となる条件は全て: (1) URL の owner/repo/N が facts.repo と --linked-issue に一致、(2) facts.decision_comment が非 null で、その url が PR 本文の URL と文字列として完全一致し、id が URL fragment の数字列と一致し、issue_url が https://api.github.com/repos/<owner>/<repo>/issues/<N> と一致する、(3) comment の author_association が OWNER / MEMBER / COLLABORATOR、(4) comment 本文に完全一致 1 行 REFERENCE_DECISION_V1: nonclosing issue=#<N> がちょうど 1 つある。comment の fresh 取得失敗(facts の decision_comment が null)・別 Issue・権限不足・marker 欠落・複数 marker・URL 不一致は A1 invalid(a1_decision_invalid)。A1 の信頼は docs/dev/ の Accepted Trust Model(operator-asserted human context、実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086)と同一であり、agent が同一 principal の identity で投稿した comment を排除するものではない。この限界を workflow.md に明記する。
  • A2 contract deferred: 対象 Issue 本文の Runtime Verification Applicability が docs/dev/runtime-verification-policy.md の正規形(decision: deferred、deferred_destination の destination_type: phase と destination_ref: post-merge-live-evidence)を満たす。post-merge-live-evidence は本 Issue で runtime-verification-policy.md に追記する予約 literal で、既存 enum・必須 field は変更しない。
    • parser は新規 regex を独自実装せず、既存 SSOT を再利用する: section の抽出は .claude/skills/create-issue/scripts/prose_boundary_policy.py の extract_level2_section_with_bounds()(fenced code block 内の見出しを除外、level-3 以降の nested 見出しで終端しない。validate_pr_body.py が既に implementation_landed_evidence.py を load している方式と同じく importlib.util.spec_from_file_location + 一意な module 名で path 指定 load し、同名 module 衝突を避ける)。section の複数検出は、1 回目の戻り値の end_index 以降の行に対する再抽出が None 以外を返すかで判定する(返れば複数 → 不成立で fail_closed / runtime_applicability_unresolved)。key の読み取りは validate_issue_body.py の LP020 と同じ単純な行形式 - key: value(deferred_destination 配下の destination_type / destination_ref も同形)に限り、decision が 3 enum 以外・欠落・複数行、deferred_destination / deferred_verification_condition(非空)の欠落は解釈不能として row 5 へ送る。section 自体の欠落は row 5(A1 valid の場合は row 1 が先に確定するため影響しない)。
  • A3 close-ready: Runtime Verification Applicability の decision が not_applicable / immediate、または deferred で destination が A2 以外。
  • decision と effective kind の verdict は上記の組合せ表を producer / validator / reviewer / impl-review repair 共通の唯一の正本とし、fail_closed は常に停止(auto repair しない)する。
  • 実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 の historical 不整合(Runtime Verification Applicability が not_applicable なのに post-merge 要件が prose にある)は A2 では表現できず、A1 でのみ non-closing になる。実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 本文は変更しない。fixture は合成データで作る。
  • reviewer の経路: pr-reviewer-lite の allow-list は Closes #N の存在を要求するため、Refs-bound PR は lite の適用対象外であり Sonnet pr-reviewer(pr-review-judge)で扱う。この点を pr-review-judge/SKILL.md に明記し、pr-reviewer-lite.md 自体は変更しない。

post-merge identity binding(closing relation 非依存)

adapter は GitHub I/O を行わない。orchestrator は fresh snapshot の query に pullRequest.body を追加し(post-merge-cleanup/SKILL.md の snapshot 手順と task-context.md に記載)、上記 entrypoint の出力のうち 7 key(decision / level / reason_code / repo / issue_number / pr_number / pr_body_sha256。effective_kind / body_verdict / body_reason は含めない)を、snapshot JSON object の top-level key non_closing_authority(pullRequest の兄弟であり、pullRequest の内側ではない)として添える(形は docs/dev/task-context.md に記載)。producer(open_pr.py)は同じ 7 key の dict を classify_closing_issue_relation(..., non_closing_authority=...) の引数として受け取り、consumer(adapter)は snapshot の non_closing_authority から読む。producer output → snapshot → adapter input は同一 dict の写像であり、key の追加・改名はしない。pr_body_sha256 は GitHub から取得した pullRequest.body 文字列そのものの UTF-8 bytes の SHA-256(正規化・改行変換なし)と定義する。adapter は PR 本文の grammar を再実装せず、次を全て満たす場合だけ binding を認める: closingIssuesReferences.nodes が空、non_closing_authority.decision == nonclosing_required かつ level が A1 または A2(A1 / A2 は評価時点で Issue が OPEN であることを含意するため adapter は Issue state を再判定しない)、repo(既存 _merged_evidence / _relation_repo_identity と同じく case-insensitive: 双方を lower() 正規化して比較)/ issue_number / pr_number が snapshot と一致、pr_body_sha256 が snapshot の pullRequest.body(欠落・非 string は拒否)の SHA-256 と一致。non_closing_authority は orchestrator-attested であり、既存 snapshot と同じ trust 境界(snapshot 自体の真正性を adapter が独立検証しない)にあることを task-context.md に明記する。それ以外は既存の reason code(RELATION_ISSUE_MISMATCH 等)で拒否し、書き込み 0。closing node が 1 件以上ある場合は従来規則のまま(別 Issue の node があれば拒否し、non-closing 判定へ fall through しない)。

適用 phase は --phase merged と --phase completed(main() の同一 _merged_evidence 経路)に限定する。_merged_evidence は _fresh_merged_evidence(recover / local-only)からも呼ばれるため、signature を _merged_evidence(snapshot, issue_number, pr_number, *, allow_non_closing: bool = False) のように keyword-only 引数で拡張し、merged / completed の呼び出しだけが True を渡す(既定 False は従来挙動のまま)。AC7 の parity matrix は既定値 False(non-closing を受理しない)と True の両方で固定する。--phase recover と --phase local-only(_fresh_merged_evidence 経由)は non-closing binding を受理せず従来どおり RELATION_ISSUE_MISMATCH で停止する(post-merge-cleanup/SKILL.md の決定表の行は変更しない)。signal_kind 集合・disposition / reason_code の既存値・各 phase の出力意味は変更しない。Task Context ctl / schema 側の変更が必要になった場合は Stop Condition。

producer 側(open_pr.py)は、emit_implementation_pr_observed の既存 GraphQL query(現行は number と closingIssuesReferences のみ)に pullRequest.body を追加した上で、classify_closing_issue_relation(snapshot, candidate_issue, candidate_repo=None, non_closing_authority=None) と emit_implementation_pr_observed(*, repo, pr_number, linked_issue, non_closing_authority=None) を拡張し、3 つの発行経路(新規 PR・既存 PR・canonical 既存 PR)のいずれでも、local の final_body ではなく GitHub から fresh 取得した live の PR 本文 に evaluator を実行して non_closing_authority を得る。evaluator が nonclosing_required(A1 または A2)で、closing node が空、pr_body_sha256 が snapshot の本文と一致する場合に限り、implementation_pr_observed を既存 wire のまま発行する。evaluator が fail_closed、authority が snapshot に束縛できない(hash 不一致等)、または authority 未取得の場合は、従来の NO_LINK / RELATION_ISSUE_MISMATCH 等の既存 disposition のまま発行しない。

Outcome

PR reference producer / validator / reviewer / impl-review-loop repair の判定と post-merge Task Context adapter の binding が同一の reference authority model(単一 evaluator)に従い、#2842 型(post-merge live evidence 待ち)の OPEN Issue では Refs が有効な linked reference として review・repair・merge 後の Task Context cleanup binding(implementation_pr_observed の発行と merged / completed phase の対象 Issue 束縛)まで通り、review を通過した経路では merge しても Issue は evidence readback と残 AC の確認が揃うまで OPEN のまま扱われる状態にする。merge 時点の guard は final head の PR 本文に対する reviewer の fresh な evaluator 実行であり(update_pr.py は facts 未供給の従来 LP057 のため、review 後の本文編集は次の review で検出する)、workflow.md に orchestrator が merge 直前に entrypoint を再実行し pr_body_sha256 を attested 値と照合する手順を記載する。通常の close-ready Issue は従来どおり Closes で閉じる。impl-review-loop の intake における context URL の provenance 判定(build_intake_capsule.py)は Refs-only PR に対し引き続き fail-closed であり、本 Issue の対象外とする。同様に、worktree / branch 削除を実行する scripts/agent-ops/cleanup_exec.py::_verify_linked_issue(現行は closingIssuesReferences または research fallback を要求し、Refs-bound PR に linked_issue_number を渡すと LINKED_ISSUE_MISMATCH で停止する。fresh main で再確認済み)の closing relation 非依存認可は本 Issue の対象外であり、dedupe 済みの follow-up Issue(Out of Scope 参照)が所有する。それまで Refs-bound PR の削除系 cleanup は安全側(削除なし)に停止したままで、post-merge-cleanup/SKILL.md にこの既知の制限を記載する。

Runtime Verification Applicability

decision: immediate
reason: Allowed Paths の .claude/skills/pr-review-judge/SKILL.md / .claude/skills/post-merge-cleanup/SKILL.md / .claude/skills/open-pr/SKILL.md は docs/dev/extension-surface-runtime-policy.yaml の skill-invocation-procedure-or-contract-change(skill-invocation-runtime-smoke)および subagent-lifecycle-start-stop-delegation-fallback(subagent-lifecycle-causal-evidence-smoke)の hard selector に該当し、default_decision: immediate である。免除条件(runtime 非読込・実行意味不変)は満たさない。#2842 の live smoke 自体は本 Issue の AC に含めない。
applicable_acs: [AC9]
execution_environment: current-head LOOP_PROTOCOL worktree と current Claude Code runtime。既存の scripts/agent-ops/run_worktree_agent_runtime_smoke.py を --mode structured で実行するだけとし、新しい harness・runner・恒久 runtime gate は追加しない。fixture(prompt と output schema)は GitHub へ mutation を行わない合成データのみを使う。
skip_conditions: claude 実行ファイルまたは uv が利用不能な場合は exit 77 + stdout 先頭 SKIP: で停止し、AC9 を PASS 扱いしない(docs/dev/runtime-verification-policy.md の SKIP 規約)。
fallback_policy: AC1〜AC7 の unit / subprocess test の PASS を AC9 の代替にしない。AC9 は変更後の pr-review-judge が実 runtime の SubAgent 経由で Refs-bound の合成 fixture を扱えることの確認であり、判定の意味は AC1〜AC7 が担う。
artifact_requirements: runner が出力する bounded な evidence(current-head identity、Claude Code 版、結果)を PR 本文に要約する。raw transcript・secret は記載しない。新しい artifact 形式は追加しない。
runtime_assertion_bindings:

  • profile: skill-invocation-runtime-smoke
    assertion: procedure_steps_executed_in_declared_order
    ac: AC9
  • profile: skill-invocation-runtime-smoke
    assertion: output_contract_schema_fields_present
    ac: AC9
  • profile: subagent-lifecycle-causal-evidence-smoke
    assertion: subagent_start_stop_causal_evidence_correlated
    ac: AC9

In Scope

  • 上記 evaluator と CLI entrypoint の実装(validate_pr_body.py)、open_pr.py の reference 選択(evaluator の結果を使う)と non-closing PR の implementation_pr_observed 発行(live の PR 本文で評価)、open-pr/SKILL.md の契約記載。A1 の Reference-Decision: 行と REFERENCE_DECISION_V1 marker、A2 の予約 literal post-merge-live-evidence、non_closing_authority の形を本 Issue の固定契約として追加する。
  • validate_pr_body.py の LP057 は facts 未供給なら従来どおり、facts 供給時は evaluator の結果に従い、同一 linked Issue の妥当な Closes / Refs を認め、番号違い・全 closing keyword・authority に反する reference を拒否する。
  • pr-review-judge/SKILL.md Step 1 が entrypoint の結果で linked Issue を Closes または Refs から特定し、Closes 不在だけで REQUEST_CHANGES にしない。missing / mismatched / unknown authority は fail closed。同 SKILL.md の Closes 不足を機械的修正対象とする記述(verdict 決定節)を含め、Closes 不足に言及する全箇所を policy-qualified にする。pr-reviewer-lite が Refs-bound PR の対象外であることを明記する。
  • impl-review-loop の legacy な Refs-only strict-xfail 前提を policy-aware な regression に置換し、step-5-feedback-and-termination.md の ensure_closing_keyword に言及する全箇所を policy-qualified にし、entrypoint が closing_required を返した根拠なし Refs-only にのみ適用する。action 名・schema は変更しない。
  • task_context_workflow_signal.py の non-closing binding(merged / completed 限定。Outcome は Task Context cleanup binding までで、cleanup_exec の削除認可は 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 が所有)と、post-merge-cleanup/SKILL.md への「Refs-bound PR の削除系 cleanup は 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 まで LINKED_ISSUE_MISMATCH で安全側停止し、linked_issue_number 省略で迂回しない」旨の記載と、post-merge-cleanup/SKILL.md の snapshot 取得手順・決定表・「PR 本文の Closes #N 文字列は authority にしない」の記述の限定、docs/dev/task-context.md の snapshot 安全条件の更新。
  • docs/dev/workflow.md に merge と Issue close の分離、decision table と grammar の単一の正本、A1 の trust の限界、Refs-bound Issue を close してよい条件(live evidence の取得・証跡リンク・残 AC 充足の確認後に operator / orchestrator が明示的に close する)を記載する。post-merge-cleanup/SKILL.md は同 matrix を参照する。
  • runtime-verification-policy.md に予約 literal post-merge-live-evidence を追記する。

Out of Scope

Acceptance Criteria

  • AC1: producer は同一の OPEN Issue state でも authority の違い(A1 valid / A1 invalid / A2 / A3 / unknown、A1 valid かつ Runtime Verification Applicability section 欠落を含む)だけで Closes / Refs / 停止が変わることを regression で固定する。実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 型 OPEN の明示 Refs を Closes に戻さず、CLOSED は Refs、不明・矛盾時は誤 close に進まず停止する。
  • AC2: evaluator と validator は decision table の全行を fixture matrix で固定する。全 closing keyword(Fixes / Resolves / Close 等)、cross-repo 形(Fixes <owner>/<repo>#N)と issue URL 形、通常 prose(fixes the typo / resolved by ... / closes the loop は reference として無視され fail_closed にならない negative fixture。keyword 直後が #N / <owner>/<repo>#N / issue URL の場合のみ closing 候補)、Closes と Refs の併存(effective kind は closing)、同種別の重複、code fence / 引用内の closing keyword(decision ごとの写像に従う: nonclosing_required と closing for other では検出して blocker、closing_required では fence / 引用内のみの対象 closing は repair / closing_missing で valid にならない。2 つを別 fixture case とする)と Refs(参照として数えない)、Related issue: のみ(notes-only。OPEN では block、CLOSED では valid)、CLOSED × {Refs, Closes, Notes のみ, 参照なし, Notes 番号違い} の写像、番号違い、prefix collision、A1 invalid を含み、nonclosing_required での closing keyword と closing_required での根拠なし Refs-only / none を拒否する。さらに wire 契約を固定する: facts JSON の exact keys(未知 key・型違い・欠落は facts_invalid)、evaluator output の exact keys / enum、pr_body_sha256 が --body-file の bytes(CRLF を含む本文で改行正規化した場合と値が異なること)から算出されること、--evaluate-reference-policy と既存 --body-file / --linked-issue / --linked-issue-body-file / --reference-facts-file の関係(必須引数の欠落は facts_invalid、decision によらず exit 0)、A1 comment URL と PR 本文 Reference-Decision: URL の exact 一致(id・issue_url・repo・番号の不一致は A1 invalid)、Reference-Decision: 行が 2 行以上(同一 URL を含む)は a1_decision_ambiguous で fail_closed(A2 / A3 へ降格しない)、A2 section の欠落・重複・fenced code block 内の偽 section・nested 見出し・解釈不能な decision。facts 未供給の LP057 は従来挙動のままで、update_pr.py 経由の close-ready Issue の body 更新は退行しない。A2 の予約 literal は runtime-verification-policy.md の記載と一致する。
  • AC3: pr-review-judge/SKILL.md Step 1 は entrypoint の実行コマンドと reason code を明記し、Refs 経由でも Issue contract を取得して AC / evidence を通常どおり評価する。テストは文書化された command 行が実在すること、同 entrypoint が matrix 上で期待どおりの decision を返すこと、SKILL.md が同じ reason code を参照することを確認する(reviewer 本体は LLM の prose であり、残る gap は AC9 の runtime 確認が担う)。pr-reviewer-lite が Refs-bound PR の対象外であることの記載、および Closes 不足に言及する全箇所が policy-qualified であること(無条件の指示が残らないこと)も確認する。
  • AC4: production の task_context_workflow_signal.py(CLI の subprocess 実行)で、(a) 有効な non_closing_authority(A1 / A2)付きの merged PR は対象 Issue に bind され、adapter が GitHub への close を一切行わず close 権限を返さない、(b) closing node なし + attestation 欠落 / decision 不一致 / level が A3 または CLOSED / 番号・PR 番号・repo 不一致 / pr_body_sha256 不一致 / pullRequest.body 欠落・非 string は既存 reason code で拒否され書き込み 0、(c) closing node がある場合の従来挙動が不変、(d) --phase recover と --phase local-only は non-closing binding を受理せず従来どおり停止し書き込み 0、(e) --phase completed は merged と同じ binding 判定、を regression で固定する。producer 側は 3 つの発行経路(新規・既存・canonical 既存)それぞれで live の PR 本文に基づき、evaluator が nonclosing_required かつ hash が束縛できる場合のみ implementation_pr_observed が既存 wire のまま発行され、evaluator が fail_closed・hash 不一致・authority 未取得の場合は従来の disposition のまま発行されないことを固定する。
  • AC5: workflow.md と post-merge-cleanup/SKILL.md が同一の decision table と close gate(merge と Issue close の区別、live evidence 欠落中は OPEN、証跡リンクと残 AC 充足後のみ operator / orchestrator が close 可、merge 時 guard は final head 本文に対する fresh な evaluator 実行と merge 直前の pr_body_sha256 照合)を記載し、2 文書の table が一致し、post-merge-cleanup/SKILL.md の「Closes 文字列は authority にしない」記述が限定された規則に更新されていることを regression で固定する。post-merge-cleanup/SKILL.md が Refs-bound PR の削除系 cleanup は 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891 まで LINKED_ISSUE_MISMATCH で安全側停止し linked_issue_number の省略で迂回しない旨を記載していることも固定する。この AC は文書契約であり、実動作の検証は AC4 が担う。
  • AC6: step-5-feedback-and-termination.md は ensure_closing_keyword に言及する全箇所で entrypoint の decision に従い(無条件の指示を残さない)、closing_required の根拠なし Refs-only だけを repair / block し、nonclosing_required + Refs は valid、nonclosing_required + closing keyword は blocker、fail_closed は auto repair せず停止する。regression は entrypoint を matrix 上で実行し、step-5 が同じ command と reason code を参照することを確認する。legacy の Refs-only 前提は置換し、既存 fixture は変更しない。
  • AC7: producer 側 classifier(open_pr.py の classify_closing_issue_relation(..., non_closing_authority=None))と consumer 側 classifier(task_context_workflow_signal.py の _merged_evidence)が、同一の snapshot(pullRequest.body を含む)+ non_closing_authority fixture matrix で同じ accept / reject 判定になる parity regression を持つ(同名 module 衝突を避け path 指定で import する)。snapshot の non_closing_authority は top-level key(pullRequest の兄弟)で、producer には同一 dict を引数として渡す。fixture matrix の各 case は (snapshot, authority) の組で、accept は「producer が NO_LINK / RELATION_ISSUE_MISMATCH 以外 ⇔ consumer が binding 成立」、reject は双方が既存 reason code で拒否と定義し、最低限 valid A1 / valid A2 / level A3 / level CLOSED / authority 欠落 / pr_body_sha256 不一致 / repo(別 repo は reject、case 違いのみは accept)・issue・PR 番号の各不一致 / decision: closing_required / pullRequest.body 欠落 / 同一 Issue の closing node あり / 別 Issue の closing node あり を含む。
  • AC8: 既存の通常 PR selection と reviewer gate を退行させず、標準品質ゲートと既存の update_pr.py 検証テストを通す。実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 / fix: trusted human-context contract-update の安全性と producer 到達性を修正 #2861 に変更を加えず、変更ファイルは Allowed Paths 内に収まる。
  • AC9: 変更後の pr-review-judge Skill を current Claude Code runtime の SubAgent 経由で起動し、post-merge-pending の Refs-bound 合成 fixture に対して Step 1 が Closes 不在だけで REQUEST_CHANGES とせず linked Issue を Refs から特定する手順を宣言順に実行し、出力契約の全 field を返し、SubAgent の start / stop の causal evidence が実行と相関することを実 runtime で確認する。SKIP は PASS ではない。 検証は runner の既存 flag で実体化する: --expect-ordered-marker を pr-review-judge/SKILL.md の Procedure の宣言順(Step 1 linked Issue 特定 → AC / evidence 評価 → verdict 出力)に対応する 3 つの literal marker で渡し(fixture prompt が SubAgent に各 Step 完了時にその literal を出力させる。marker は実装時に SKILL.md の Procedure 見出しと突き合わせて確定する)、--output-schema-path は本 Issue が追加する単一の fixture 用 JSON Schema(reference_policy_runtime_smoke.output.schema.json。pr-review-judge の出力契約の最小 convention である verdict / reviewed_head_sha / blockers / warnings と smoke 用 linked_issue_resolution / smoke_marker を required とする。汎用 schema registry や新しい runner 機能は作らない)で最終応答の JSON を full validation する。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/open-pr/scripts/tests/test_open_pr_validation_hook.py::test_given_authority_matrix_when_selecting_reference_then_closes_or_refs_or_stop
# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/open-pr/scripts/tests/test_validate_pr_body.py::test_given_reference_policy_matrix_when_validated_then_accept_or_reject .claude/skills/open-pr/scripts/tests/test_validate_pr_body.py::test_given_reference_facts_wire_when_evaluated_then_exact_keys_and_body_bytes_hash
# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py::test_given_refs_binding_when_step1_then_issue_resolved_by_entrypoint_not_closes_only
# AC4
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_non_closing_authority_when_merged_phase_then_binds_without_close_authority tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_invalid_non_closing_authority_when_merged_phase_then_rejected_with_zero_writes tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_closing_node_when_merged_phase_then_legacy_behavior_unchanged tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_recover_or_local_only_phase_when_non_closing_authority_then_still_rejected tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_non_closing_pr_when_open_pr_observed_then_signal_emitted_only_when_authority_binds_to_live_body
# AC5
# baseline-expect: fail
$ uv run --locked pytest tests/test_post_merge_cleanup_boundary.py::test_given_close_gate_matrix_when_compared_then_workflow_and_post_merge_skill_match
# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_handoff_pr_hygiene_regression.py::test_given_reference_policy_matrix_when_repairing_then_closing_keyword_only_for_closing_required
# AC7
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_fixture_matrix_when_classified_then_producer_and_consumer_agree
# AC8
$ pnpm typecheck
# AC8
$ pnpm lint
# AC8
$ pnpm test
# AC8
$ pnpm build
# AC8
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py
# AC8
$ uv run --locked pytest .claude/skills/open-pr/scripts/tests/test_update_pr_validation_hook.py
# AC9
# 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/pr-review-judge/tests/fixtures/reference_policy_runtime_smoke.prompt.md --output-dir artifacts/runtime-smoke/reference-policy --evidence-json artifacts/runtime-smoke/reference-policy.evidence.json --require-subagent-causal-evidence --expect-marker REFERENCE_POLICY_SMOKE_OK --expect-ordered-marker REFERENCE_POLICY_STEP1_LINKED_ISSUE_RESOLVED_FROM_REFS --expect-ordered-marker REFERENCE_POLICY_STEP_AC_EVIDENCE_EVALUATED --expect-ordered-marker REFERENCE_POLICY_STEP_VERDICT_EMITTED --output-schema-path .claude/skills/pr-review-judge/tests/fixtures/reference_policy_runtime_smoke.output.schema.json

Allowed Paths

  • .claude/skills/open-pr/SKILL.md
  • .claude/skills/open-pr/scripts/open_pr.py
  • .claude/skills/open-pr/scripts/validate_pr_body.py
  • .claude/skills/open-pr/scripts/tests/test_open_pr_validation_hook.py
  • .claude/skills/open-pr/scripts/tests/test_validate_pr_body.py
  • .claude/skills/pr-review-judge/SKILL.md
  • .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py
  • .claude/skills/post-merge-cleanup/SKILL.md
  • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
  • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md
  • .claude/skills/impl-review-loop/tests/test_handoff_pr_hygiene_regression.py
  • tests/task-context/test_post_merge_workflow_signal_adapter.py
  • tests/test_post_merge_cleanup_boundary.py
  • docs/dev/workflow.md
  • docs/dev/task-context.md
  • docs/dev/runtime-verification-policy.md
  • .claude/skills/pr-review-judge/tests/fixtures/reference_policy_runtime_smoke.prompt.md
  • .claude/skills/pr-review-judge/tests/fixtures/reference_policy_runtime_smoke.output.schema.json

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • Task Context の signal_kind 集合・disposition / reason_code 既存値の変更、または Task Context ctl / schema 側の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 参照選択の authority が確定しない、または 実装: trusted human-context の contract_update mutation lane が、freeform directive から不正な patch operation を導出し、失敗理由を出さずに停止する欠陥を是正する #2842 の OPEN 維持・明示 Refs decision に反する実装が必要になった場合
  • 自動 close 実行器や新 ledger / schema を追加しないと AC を満たせないと判明した場合

Required Skills

なし

Required Design References

  • docs/dev/workflow.md
  • docs/dev/runtime-verification-policy.md
  • docs/dev/task-context.md
  • .claude/skills/open-pr/SKILL.md
  • .claude/skills/pr-review-judge/SKILL.md
  • .claude/skills/post-merge-cleanup/SKILL.md
  • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md

Delivery Rule

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    follow-up
    on Oct 2, 2026
  2. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    Findings

    P0 — Refs を採用すると、現行 post-merge-cleanup の通常経路が対象 Issue を特定できない

    これは現状の #2878 で最も大きい契約欠陥です。

    #2878 は「post-merge evidence pending の OPEN Issue → Refs #N」を正規ケースにしたうえで、merge 後に post-merge-cleanup が evidence を確認して close gate を処理する設計です。しかし current main の post-merge-cleanup は、merged PR の Issue identity を GraphQL の closingIssuesReferences から取得しています。

    具体的には:

    • .claude/skills/post-merge-cleanup/SKILL.md
      • fresh merged-PR snapshot の closingIssuesReferences(...) を relation authority とする
      • PR本文の Closes #N 文字列自体も authority にはしない
    • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
      • pr["closingIssuesReferences"]["nodes"] を直接読む
    • .claude/skills/open-pr/scripts/open_pr.py
      • implementation_pr_observed signal も同じ closingIssuesReferences を使い、0件なら NO_LINK

    一方、GitHub が PR↔Issue の closing relation として扱うキーワードは close/closes/closed/fix/fixes/fixed/resolve/resolves/resolved で、Refs は含まれません。リンクされた PR を default branch に merge すると Issue を自動 close するのが GitHub の標準セマンティクスです。[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) GitHub CLI も PR 側には closingIssuesReferences、Issue 側には closedByPullRequestsReferences を公開しています。GitHub CLI

    つまり #2842 型 PR を Refs #2842 にすると、「auto-close は防げる」が「現行 post-merge relation authority から #2842 が消える」という構造です。

    Impact: #2878 の中心ユースケースが、merge 後に通常 cleanup lane へ入らず NO_LINK / relation unavailable 側へ落ちる可能性が高いです。producer / validator / reviewer だけ直しても destination に到達しません。

    最小修正: Refs ケースで post-merge が使う Issue identity の authority を契約に追加する必要があります。新しい大掛かりな harness は不要です。既存 Task Context が保持する explicit issue_number / implementation claim 等を再利用できるなら、それを closing relation とは独立した authoritative binding とするのが最も自然です。これに伴い少なくとも以下は Allowed Paths / regression 対象の再検討が必要です。

    • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
    • tests/task-context/test_post_merge_workflow_signal_adapter.py
    • 必要なら docs/dev/task-context.md

    逆にここを別 Issue に分けるなら、#2878 の Outcome から「post-merge close gate を実動作まで整合する」を外し、明示 dependency にするべきです。


    P1 — 「post-merge evidence pending」を機械的に判定する authority がまだ定義されていない

    #2878 は「フリーテキストの曖昧なキーワードだけで post-merge gate を推測しない」「機械的に確定できなければ fail closed」と明記しています。これは正しい方針ですが、現在の contract には、その機械的 authority が何かがありません。

    current open_pr.py が取得しているのは Issue state だけです。

    OPEN   -> default Closes
    CLOSED -> default Refs
    

    既存 Refs #N が本文にある場合は caller intent として保存します。実際、test_open_pr_validation_hook.py には既に「OPEN Issue に既存 Refs があれば保存する」という regression があります。

    つまり AC1 の難しい部分は「Refs を保存する」ことではなく、

    参照が未指定の OPEN Issue について、何を根拠に close-ready / post-merge-pending を分類するか

    です。

    ここで代表例の #2842 に別の不整合があります。#2842 は AC6/AC7 で「merge 後の live canonical main subprocess evidence を取るまで OPEN」と要求しているのに、Runtime Verification Applicability は decision: not_applicable です。ところが canonical docs/dev/runtime-verification-policy.md では not_applicable は「静的検証のみで完結し runtime 証跡不要」、deferred は後続 Issue/phase/milestone と検証条件を明示するもの、と定義されています。

    そのため、#2842 の prose を読めば人間には意図が分かりますが、既存の structured SSOT からは逆の信号が出ています。

    Impact: AC1/AC2/AC3 を実装すると、次のどちらかになりがちです。

    最小修正: reference-policy の authority hierarchy を Issue に明示すべきです。例えば既存 SSOT を使うなら、

    1. explicit trusted human reference decision が存在し、対象 Issue と exact bind → それを尊重
    2. structured Runtime Verification contract が deferred かつ destination phase が post-merge → Refs
    3. post-merge requirement なし・close-ready → Closes
    4. structured authority が矛盾/不足 → fail closed

    のようにできます。

    特に #2842 型は Runtime Verification Applicability: deferred + destination_type: phase + post-merge canonical-main condition で表せる余地があります。新 schema を作る前に、既存 policy で表現可能かを詰める方がこの個人開発には適しています。


    P1 — AC4 の Verification Command は現在 false-green

    AC4 は、

    workflow / post-merge cleanup の close gate を記載し、live evidence 欠落中 OPEN、充足後のみ close 可を matrix で regression 固定

    と要求しています。

    しかし AC4 の唯一の command は:

    uv run --locked pytest \
      .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py

    current main のこの test file を確認すると、post-merge-cleanup、docs/dev/workflow.md、close gate matrix を検証していません。Closes #N が reviewer Step 1 の issue-resolution authority である、という既存契約の assertion があるだけです。

    したがって、post-merge-cleanup/SKILL.md と docs/dev/workflow.md を一文字も変更しなくても AC4 command が green になり得ます。

    Impact: #2878 の最重要 destination の一つがテストされず、PR review は false-green になります。

    最小修正: 既存テスト資産を使って behavioral regression を追加すべきです。候補は:

    • tests/task-context/test_post_merge_workflow_signal_adapter.py
    • tests/test_post_merge_cleanup_boundary.py

    少なくとも「Refs-bound implementation issue + merged PR + evidence pending → OPEN」「evidence complete/readback valid + remaining AC complete → close eligible」の matrix が production consumer に届く必要があります。単なる SKILL.md の文字列 assertion だけでは不足です。


    P1 — impl-review-loop に逆方向の「Refs-only は修正対象」という契約が残っている

    #2878 の Allowed Paths は pr-review-judge までは含みますが、review 結果を修復する impl-review-loop 側を含みません。

    current main では:

    • .claude/skills/impl-review-loop/tests/test_handoff_pr_hygiene_regression.py
      • Refs #N only は「Closes 欠落なので failure であるべき」という legacy strict-xfail が残る
      • コメントも Refs-only を ensure_closing_keyword 対象として記述
    • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md
      • body-only repair の例として ensure_closing_keyword
    • .claude/agents/implementation-worker.md
      • ensure_closing_keyword → update_pr_body_hygiene → open-pr/scripts/update_pr.py

    という契約が残っています。

    さらに build_intake_capsule.py の PR conversation comment provenance binding も _pr_closes_target_issue() を使い、closingIssuesReferences が対象 Issue を含むことを要求しています。Refs-only PR 上の trusted context/report URL を impl-review intake に渡すケースでは reject されます。

    Impact: pr-review-judge を Refs-aware にしても、隣接 consumer が Closes-only 前提を維持し、将来 regression や自動修復で Refs を Closes に戻す余地が残ります。

    最小修正: 少なくとも legacy regression を policy-aware に変える必要があります。

    • close-ready OPEN + Refs-only → 修正対象
    • post-merge-pending OPEN + Refs-only → valid
    • post-merge-pending OPEN + Closes → blocker
    • authority unknown → fail closed

    ensure_closing_keyword という action 名まで一般化するかは別判断でよく、#2878 で無理に schema/action 名を増やす必要はありません。まず既存 regression の意味を直すのが小さい変更です。


    P2 — AC1/AC2 は既存機能の再確認だけで部分 green になりやすい

    current main では既に:

    • OPEN → default Closes
    • CLOSED → default Refs
    • OPEN でも PR body に explicit Refs があれば保存
    • LP057 validator は matching Closes #N と Refs #N の両方を認める
    • linked issue 番号が違えば reject

    まで実装済みです。

    そのため AC1/AC2 のテストを素直に増やすだけだと、「新しい reference-policy authority を実装していないのに大半が PASS」という状態になり得ます。

    AC1/AC2 では単なる keyword matrix ではなく、同じ OPEN Issue state に対して authority input の違いだけで Closes/Refs/reject が変わることを regression の中心にした方がよいです。


    外部仕様との照合

    GitHub の native model は基本的に「linked PR = merge 時に Issue を閉じる relation」です。supported closing keywords に Refs はなく、manual Development link も default branch merge 時の auto-close 対象です。[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)

    したがって、Refs を「non-closing linked Issue」として採用する場合、GitHub native closingIssuesReferences をそのまま Issue identity SSOT にすることはできません。ここは repository-owned workflow が explicit relation を保持する必要があります。gh pr view と gh issue view の公開フィールドも closing relation と closed-by relation に分かれています。[GitHub CLI](https://cli.github.com/manual/gh_pr_view?utm_source=chatgpt.com)


    その他の live state

    確認時点で #2878 自体にコメントはなく、2878 を参照する implementation PR も検索結果にはありませんでした。したがって Issue contract を修正するなら、まだ実装差分との互換性を気にせず直せる段階です。

    Issue 本文の overlap preflight も一部 stale です。#2872 は現在 CLOSED。一方 #2838 / #2825 / #2820 は OPEN でした。着手時 fresh preflight を行うという Delivery Rule 自体は正しいので、これは blocker ではありません。

    推奨する refinement

    現状のまま実装へ入るより、#2878 を一度 refinement した方がよいです。追加すべきものは大きな security/harness layer ではなく、次の4点だけで十分です。

    1. non-closing Refs PR を post-merge でどの authoritative Issue identity に bind するかを明示する。
    2. close-ready / post-merge-pending の機械的 authority を既存 Runtime Verification SSOT 等へ固定する。
    3. AC4 を実際の post-merge consumer test で検証する。
    4. impl-review-loop に残る Closes-only regression を policy-aware に整合する。

    この4点を解決しない場合、producer/validator/reviewer だけは整っても、#2842 型の本来のシナリオは 「Refs にしたため auto-close は防げたが、merge 後の canonical workflow が Issue を見失う」 という別の failure mode に移る可能性があります。

  3. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    live GitHub を確認したところ、#2878 は現在 OPEN、対象コメント #issuecomment-5963286403 は repository OWNER によるコメントで、現時点では #2878 を参照する実装 PR は見つかりませんでした。対象コメントは current contract に対し、post-merge binding、reference authority、AC4 の false-green、impl-review-loop の Closes-only 前提を具体的に指摘しています。

    推奨アクションは、対象コメントを operator-selected trusted human context として current issue-refinement-loop に投入し、単なる再レビューではなく Issue contract の実修復 → fresh review → approved termination まで進めることです。特に、現在の Allowed Paths にないファイルが必要なこと自体を停止理由にせず、同じ Outcome 内の最小限の scope expansion は今回の明示承認として扱わせます。

    Repository: squne121/loop-protocol

    対象:

    既に auto mode で起動しているこの対話的 Claude Code session をそのまま使用してください。新しい session を開始しないでください。

    Objective

    Issue #2878 に対して current HEAD の issue-refinement-loop を実行し、上記 OWNER anchor の findings を current repository evidence と照合したうえで Issue contract を実際に修復し、canonical review loop を approved または genuine な repository-defined human_judgment_required の terminal condition まで完遂してください。

    今回は「調査して提案するだけ」ではありません。必要な Issue 本文 mutation、再レビュー、fresh readback、termination publish まで実行してください。

    ただし refinement 完了後に implementation を開始してはいけません。impl-review-loop、implementation worker、implementation worktree、implementation PR 作成には進まず、issue-refinement-loop の正常終了点で停止してください。

    Explicit operator authorization

    私は repository owner/operator として、この refinement を完了するために必要な以下の非破壊的作業を明示的に承認します。

    • 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の current Issue body / comments / related Issues / PRs / main HEAD の fresh 取得
    • 指定 OWNER anchor の human-context としての消費
    • current canonical Skill / Agent / SSOT / scripts / tests の read-only 調査
    • issue-refinement-loop が必要とする dedicated refinement worktree の作成または既存 canonical worktree の再利用
    • codebase-investigator 等の適切な SubAgent の使用
    • 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の Issue contract の編集
    • In Scope / Out of Scope / Outcome / AC / Verification Commands / Allowed Paths / Required Design References / Stop Conditions / Delivery Rule 等の整合化
    • anchor が要求する同一 Outcome 内の最小限の Allowed Paths expansion
    • current-main investigation により判明した、同じ root cause / Outcome を完結させるため不可欠な exact repository-relative path の追加
    • false-green Verification Command の behavioral regression への修正
    • stale な overlap / related-state 情報の fresh evidence に基づく更新
    • canonical publisher / controlled mutation lane を介した refinement 終了コメントの投稿
    • review finding に対する bounded な自動修正と再レビュー
    • 再発防止が 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 本体とは独立した恒久対策として必要だと fresh evidence で確認された場合の follow-up GitHub Issue 起票

    この承認は、既存 canonical guard / permission / freshness / provenance check を迂回する許可ではありません。--dangerously-skip-permissions や permission bypass を使用しないでください。

    また以下は承認していません。

    Fresh-state first

    過去の会話や anchor 内の「current main」記述をそのまま current fact とみなさないでください。

    最初に fresh に以下を取得してください。

    1. 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の本文、全コメント、state、updatedAt
    2. anchor comment 5963286403 の full body、author association、identity
    3. current main HEAD
    4. 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 に関連する既存 PR の有無と状態
    5. current overlap / related Issue / PR state
    6. current .claude/skills/issue-refinement-loop/SKILL.md
    7. Skill が現在参照する relevant references
    8. 必要な current repository assets

    少なくとも anchor の findings に直接関係する以下を current HEAD から確認してください。

    • .claude/skills/post-merge-cleanup/SKILL.md
    • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
    • .claude/skills/open-pr/SKILL.md
    • .claude/skills/open-pr/scripts/open_pr.py
    • .claude/skills/open-pr/scripts/validate_pr_body.py
    • .claude/skills/pr-review-judge/SKILL.md
    • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md
    • .claude/skills/impl-review-loop/tests/test_handoff_pr_hygiene_regression.py
    • relevant impl-review-loop intake/provenance code
    • .claude/agents/implementation-worker.md(finding が現在も relevant なら read-only 確認)
    • tests/task-context/test_post_merge_workflow_signal_adapter.py
    • tests/test_post_merge_cleanup_boundary.py
    • docs/dev/runtime-verification-policy.md
    • docs/dev/workflow.md
    • 必要なら docs/dev/task-context.md

    ファイル名や役割は anchor から推測せず、current repository の実体を確認してください。

    Treat the OWNER anchor as a technical directive requiring resolution

    anchor の各 finding を independently validate してください。単に文章として Issue にコピーしないでください。

    特に以下を解決してください。

    1. non-closing Refs と post-merge Issue identity

    Refs #N を採用した場合、GitHub native closingIssuesReferences から対象 Issue が消える現在の consumer behavior を fresh code で確認してください。

    #2878 の Outcome が「post-merge close gate を実動作まで整合する」ことを維持するなら、non-closing PR を post-merge workflow がどの authoritative binding によって対象 Issue へ結び付けるのかを contract に明確化してください。

    既存 Task Context の explicit issue_number / implementation claim / repository-owned binding 等を再利用可能なら、新規の大規模 registry や harness を作るより既存 mechanism の再利用を優先してください。

    一方、current architecture 上どうしても別 Outcome になるなら canonical scope/dependency mechanism に従って分離してください。単に Allowed Paths が現在狭いという理由だけで人間へ戻さないでください。

    2. close-ready / post-merge-pending の mechanical authority

    同じ OPEN state でも reference decision が変わるため、単なる Issue state や prose heuristic に依存しない mechanical authority hierarchy を定義してください。

    anchor の提案は候補であり、そのまま固定実装せず current SSOT と照合してください。

    優先して検討するもの:

    • exact target に bind された explicit trusted human reference decision
    • existing structured Runtime Verification contract
    • existing Task Context / workflow contract
    • contradiction / insufficient authority 時の fail-closed

    新 schema / ledger / wrapper を追加する前に、既存 canonical SSOT で表現できるか確認してください。

    #2842 の body 自体は変更禁止です。#2842 の historical inconsistency が fixture として重要でも、#2878 refinement のために #2842 を mutation しないでください。

    3. AC4 false-green の除去

    AC4 は post-merge consumer の behavior を要求しているため、pr-review-judge の contract-drift test だけが green でも AC4 が満たされたことにならないようにしてください。

    少なくとも current production consumer path を使い、

    • valid non-closing binding + merged PR + evidence pending → Issue remains OPEN / close-ineligible
    • required evidence/readback + remaining AC complete → close eligibility が成立
    • missing / mismatch / ambiguous binding → fail closed

    等の本質的 behavior を regression で固定できる Verification Command にしてください。

    単なる Skill prose の文字列 assertion だけで destination を green にしないでください。

    4. impl-review-loop に残る Closes-only semantics

    pr-review-judge だけ Refs-aware にしても downstream repair/intake が Refs-only を無条件で defect と扱うなら end-to-end contract は不整合です。

    current code/tests を確認し、最低限以下の policy matrix が system-wide に矛盾しない contract になるよう #2878 を refinement してください。

    • close-ready OPEN + unjustified Refs-only → repair/block
    • post-merge-pending OPEN + authoritative Refs-only → valid
    • post-merge-pending OPEN + Closes → blocker
    • unknown / contradictory authority → fail closed
    • CLOSED Issue → appropriate non-closing reference

    ensure_closing_keyword 等の action/schema 名を一般化する必要が本当にあるかは current design から判断してください。具体的 defect を解消しない抽象化追加は避けてください。

    build_intake_capsule.py 等に closing-relation-only provenance binding が残っている場合も、対象 scenario に影響するか fresh に確認してください。

    Scope expansion handling

    現在の #2878 body の Allowed Paths が anchor findings を完全には cover していないことは既知です。

    今回の operator instruction は、同じ #2878 Outcome を完結させるための 最小限の path expansion を明示的に承認しています。

    anchor に exact path literal がある場合は current issue-refinement-loop の trusted human-context contract に従って利用してください。

    exact path が anchor に無く、architecture/workflow-level directive から追加 path が必要な場合は、current anchor-comment-handling contract が許すなら codebase-investigator SubAgent を read-only で使い、current main から exact repository-relative paths を導出してください。

    その investigation evidence を canonical preflight と mutation phase の双方へ current Skill の規定どおり伝播してください。

    NEXT_ACTION: issue_editor_required が返った場合、それは停止指示ではありません。current Skill の canonical issue-editor/full-rewrite route を実行し、その後 fresh readback → fresh preflight に戻ってください。

    SubAgent requirements

    適切な SubAgent を積極的に使用してください。

    最低限、scope/path/consumer wiring の調査に read-only codebase-investigator が有効なら使用してください。review phase では current issue-refinement-loop が指定する reviewer / semantic reviewer / issue editor 等の canonical agent/skill routing に従ってください。

    SubAgent へは必ず明示してください。

    親会話の暗黙 context に依存させないでください。

    重要:
    SubAgent を dispatch しただけで完了扱いにしないでください。

    各 SubAgent の terminal completion と final result を必ず取得してから、その結果を検証して downstream step へ進んでください。

    dependency の無い read-only investigations は必要なら並列化して構いません。ただし mutation / fresh readback / review の依存順序は守ってください。

    SubAgent に再帰的な nested delegation を勝手にさせず、root conversation が control-plane を保持してください。ただし current agent contract が明示的に許可・要求する場合はその SSOT に従ってください。

    Canonical refinement loop

    current issue-refinement-loop の実際の procedure を正本として、概ね以下の lifecycle を完遂してください。

    1. fresh acquisition / anchor binding
    2. canonical preflight with human context
    3. required read-only investigation
    4. deterministic structural repair または canonical issue-editor route
    5. Issue body mutation
    6. fresh GitHub body readback
    7. fresh preflight
    8. root/semantic/contract review
    9. review findings の修正
    10. fresh readback + fresh review
    11. bounded iteration
    12. approved termination publish

    古い prompt の command name や flags を優先せず、必ず current SKILL.md / command registry / references の procedure を使ってください。

    通常の needs_fix、review finding、stale body、修正可能な deterministic failure は人間への停止理由にしないでください。自動修復し、fresh evidence で再評価してください。

    Recurrence-prevention Issue

    refinement 中に、#2878 の direct scope とは独立して再発しうる root-cause defect が確認された場合は、まず OPEN/CLOSED を含め repository-wide に既存 Issue を検索してください。

    既存 Issue が同じ Outcome を所有していれば新規 Issue を作らず、その Issue を参照してください。

    重複がなく、current repository-native follow-up/materialization policy で creation-ready と確認できる場合、この invocation は再発防止 Issue の作成を明示的に承認します。

    作る場合は canonical issue creation / controlled mutation path を使い、最低限:

    を記録してください。

    「再発しそうだから」という抽象論だけで security/harness/schema/wrapper を増やさないでください。具体的 failure class を固定する最小恒久対策を優先してください。

    新規 Issue の必要性が判明したことだけを理由に、人間承認待ちで停止しないでください。この prompt は上記条件を満たす non-duplicate follow-up creation を承認しています。ただし canonical repository contract が現在の invocation とは別の不可欠な authority を要求する場合、その guard を迂回してはいけません。

    Completion criteria

    以下を満たすまで作業を継続してください。

    • OWNER anchor の各 material finding が disposition 済み
    • current Issue contract が self-consistent
    • Outcome / scope / AC / VC / Allowed Paths が implementation-ready
    • Verification Commands が destination behavior を実際に検証し false-green でない
    • relevant producer / validator / reviewer / post-merge consumer / impl-review adjacent semantics が contract 上矛盾しない
    • fresh preflight が readiness を確認
    • canonical reviews が approve
    • approved body の fresh readback / digest が確定
    • canonical termination report が投稿済み
    • dispatch した全 SubAgent の terminal result を回収済み

    approved 後は implementation を開始しないでください。

    Final report

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

    • fresh main SHA
    • anchor identity / trusted status
    • 実際に変更した 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 contract の要点
    • 追加・削除した Allowed Paths
    • authority model の最終形
    • Verification Commands の修正内容
    • preflight / root review / semantic review / joined review の最終 verdict
    • final Issue body digest / readback status
    • 作成または再利用した recurrence-prevention Issue
    • unresolved blocker があれば、その exact canonical reason
    • implementation が未開始であること

    通常の修正可能 failure を blocker として残さず、canonical loop の範囲内で修復してから報告してください。

    このプロンプトでは、対象コメントに明記された path expansion を「現 Allowed Paths 外だから即停止」と扱わず、current skill の human-context / investigation evidence 経路で吸収するようにしています。また、refinement の終了後にそのまま実装へ流れないよう明示的に境界を置いています。

  4. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    実施した契約修復(anchor findings の disposition)

    • P0(Refs 採用時の post-merge Issue identity 喪失): 現行 _merged_evidence() が closingIssuesReferences ちょうど 1 件を要求し、Refs-only は RELATION_ISSUE_MISMATCH で cleanup が停止することを一次確認。orchestrator-attested な non_closing_authority(PR 本文 SHA-256 束縛、merged / completed 限定)による closing relation 非依存 binding を契約化。
    • P1(機械的 authority 未定義): A1 explicit reference decision / A2 Runtime Verification の deferred+予約 literal post-merge-live-evidence / A3 close-ready の total な decision table と fail-closed を契約化(新 schema・ledger・自動 close 実行器は追加しない)。
    • P1(AC4 false-green): production adapter の subprocess regression(binding・拒否・phase 限定・producer emit)へ置換。
    • P1(impl-review-loop の Closes-only): policy-aware な regression へ置換する契約に更新。
    • P2(AC1/AC2 の部分 green): authority 入力の違いで結果が変わる matrix を中心に再定義。
    • 既存の欠陥の是正: 元の本文は SKILL.md が hard selector に該当するのに not_applicable で、EXTSURF001 / RUNTIMEASSERT001 を満たしていなかった。decision: immediate+runtime AC9+runtime_assertion_bindings に修正し、VC を baseline-expect の canonical 形に修正。
    • Allowed Paths: 追加 8 件(task_context_workflow_signal.py、tests/task-context/test_post_merge_workflow_signal_adapter.py、tests/test_post_merge_cleanup_boundary.py、docs/dev/task-context.md、docs/dev/runtime-verification-policy.md、impl-review-loop の step-5-feedback-and-termination.md と test_handoff_pr_hygiene_regression.py、AC9 用 pr-review-judge/tests/fixtures/reference_policy_runtime_smoke.prompt.md)。削除なし。workflow.md は元から含まれる。
    • planner が anchor から機械導出した patch plan は箇条書き断片の AC 混入と不正 path を含むため適用せず(consumer は writes 0 で fail-closed)、operator 承認の full rewrite(edit_issue_txn.py)で反映した。

    残 blocker(最終 review の findings。body には未反映)

    1. high: closing keyword の「解釈不能 → fail_closed」が広すぎ、fixes the typo / resolved by … 等の通常 prose で fail_closed になりうる。keyword 直後が # / <owner>/<repo># / issue URL の場合だけ reference 候補とし、それ以外は無視する定義へ狭め、prose の negative fixture を AC2 に追加する。
    2. medium: facts JSON と entrypoint 出力の key、pr_body_sha256 の出自(evaluator が評価した本文から算出すべき)、--evaluate-reference-policy と既存必須引数 --body-file / --linked-issue の関係、A1 comment URL と本文 URL の一致検証、updated_at の用途が未定義。固定契約として明記が必要。
    3. medium: cleanup_exec._verify_linked_issue は closing relation(または research fallback)を要求するため、Refs-bound PR では orchestrator が linked_issue_number を渡すと LINKED_ISSUE_MISMATCH になる。Outcome を「Task Context cleanup binding」に狭めるか、worker を linked_issue_number なしで dispatch する運用を post-merge-cleanup/SKILL.md に明記し、cleanup_exec の closing-relation 非依存認可を follow-up として名指しする。
    4. low: AC7 parity の snapshot key(non_closing_authority の位置)と accept / reject 写像が未定義。
    5. low: A2 の parser(policy の正規 section parser 再利用か単一形式の regex か)と、複数 Reference-Decision: 行(A1 present かつ invalid)の扱いが未定義。

    次の操作(人間判断)

    上記 5 件は本文の機械的な修正で解消できる範囲です。max_iterations の上限により自動継続は停止しました。続行する場合は、この終了コメントを anchor として issue-refinement-loop を再実行してください。

  5. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    live state を確認したところ、#2878 は OPEN・phase/implementation ですが、最新 OWNER コメント 5964870175 は issue-refinement-loop: human_escalation / max_iterations_exceeded です。実装 PR・2878 branch は現時点で存在せず、current main は f7a2cff5aa727f5b30bf86f9cb4e1440bf82fdc5。添付ログでも 5 件の semantic finding を残して refinement が停止し、implementation 未開始と記録されています。貼り付けたテキスト(1)

    したがって推奨は、実装を強行せず、最新終了コメントを anchor に refinement を1 invocationだけ再開 → approved を得た直後、このユーザー指示を実装 authority として fresh impl-review-loop entry に入り → draft_pr_ready まで自律継続です。approved handoff comment 自体を実装承認として扱わない点も明示しています。

    Repository: squne121/loop-protocol

    対象:

    この fresh な対話的 Claude Code session は既に auto mode で起動済みです。この session を継続し、新しい session を開始しないでください。

    Objective

    Issue #2878 を、人間への iteration ごとの承認要求なしで、最終的に current impl-review-loop の正常終了点である **draft_pr_ready(人間が merge 判断できる直前)**まで進めてください。

    ただし、現時点の live GitHub state では #2878 の最新 canonical refinement termination は approved ではなく、

    • human_escalation
    • cause: max_iterations_exceeded
    • deterministic review は 3 回とも approve
    • Step 2.5 semantic review に未解消 findings 5 件
    • implementation 未開始

    です。

    したがって作業は必ず次の 2 phase で行ってください。

    1. Phase A — refinement recovery
      最新 OWNER termination comment 5964870175 を operator-selected human-context anchor として、current issue-refinement-loop を新しい invocation として再開し、残る semantic findings を Issue contract へ反映して approved まで完了する。
    2. Phase B — implementation
      Phase A が canonical approved で正常終了した場合のみ、このユーザー指示そのものを明示的な implementation request / authority として、current impl-review-loop の Root-Owned Synchronous Entry Transition から fresh に開始し、実装・検証・PR review・修正を draft_pr_ready まで完遂する。

    issue-refinement-loop の approved comment や LOOP_HANDOFF_RESULT_V1 marker 自体を implementation authority として扱わないでください。Phase B の authority は、このユーザーによる明示的な実装依頼です。

    Phase A が genuine な repository-defined human_judgment_required、再度の canonical max_iterations_exceeded、またはその他の非迂回可能な terminal blocker で終了した場合は、Phase B を開始せず exact reason を報告して停止してください。

    Explicit operator authorization

    私は repository owner/operator として、この invocation の目的を達成するために必要な以下の非破壊的作業を明示的に承認します。

    Phase A: refinement recovery

    • 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の current body / 全 comments / state / labels / updatedAt の fresh 取得
    • current main HEAD の fresh 取得
    • related Issue / PR / branch / overlap state の fresh 取得
    • comment 5964870175 を operator-selected trusted human context として利用
    • original anchor 5963286403 を背景 evidence として再確認
    • current .claude/skills/issue-refinement-loop/SKILL.md と references の読込
    • relevant SSOT / scripts / tests の read-only 調査
    • 必要な read-only SubAgent の使用
    • canonical dedicated refinement worktree の作成または既存 canonical worktree の再利用
    • 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 Issue contract の controlled mutation
    • semantic review finding を解消するための Outcome / scope / AC / VC / Allowed Paths / Runtime Verification / design references / delivery rule の整合化
    • 同一 Outcome を完結させるため current canonical refinement workflow が許容する最小限の scope / Allowed Paths 調整
    • deterministic review / semantic design review / joined review の bounded retry
    • fresh body readback / digest validation
    • canonical termination report の publish
    • normal な needs-fix / review finding / stale readback / deterministic repair の自動修復

    Phase B: implementation + review loop

    Phase A が approved になった場合、以下を明示的に承認します。

    • current .claude/skills/impl-review-loop/SKILL.md の正式 entry の実行
    • current root entry / preparation / landing-disposition procedure の実行
    • dedicated implementation worktree / branch の作成、または canonical existing worktree / branch の再利用
    • current 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 contract の Allowed Paths 内の実装
    • source / tests / fixtures / docs の必要な編集
    • implementation-worker 等の current canonical implementation SubAgent の使用
    • test-runner による独立検証
    • pr-reviewer / pr-review-judge による fresh-head review
    • commit / push
    • Draft PR の作成、または既存対象 PR の再利用・更新
    • PR body / metadata の canonical producer 経由での更新
    • Verification Commands、focused tests、標準 quality gates、required CI、runtime verification の実行
    • REQUEST_CHANGES に対する bounded な自動修正
    • fix 後の再 test / fresh review
    • current main drift / branch behind / stale reviewed HEAD の canonical reconciliation
    • implementation に起因する CI failure の修正と再検証
      -必要に応じた failed CI job の bounded rerun
    • draft_pr_ready 到達までの current canonical loop iteration

    通常の test failure、review finding、REQUEST_CHANGES、stale reviewed HEAD、BEHIND、修正可能な CI failure、implementation-related mergeability warning は人間承認待ちの理由にしないでください。current Skill の routing に従って自律的に修復・再検証してください。

    Recurrence-prevention Issue

    refinement または implementation 中に、#2878 の direct Outcome とは独立した再発可能な root-cause defect が fresh evidence で確認された場合は、まず repository-wide に OPEN/CLOSED 両方の既存 Issue を検索してください。

    同じ Outcome を所有する Issue が存在すれば新規作成せず、その Issue を参照してください。

    重複がなく、current repository-native issue creation/materialization policy 上 creation-ready であれば、新規 follow-up Issue の作成を明示的に承認します。

    特に latest refinement finding 3 が current main でも成立し、cleanup_exec._verify_linked_issue の closing-relation 非依存認可が #2878 の最終 scope 外として残る場合は、既存 Issue を dedupe した上で follow-up 候補として評価してください。

    新規 Issue には最低限:

    を記録してください。

    抽象的な「再発しそう」「security を強化した方がよい」という理由だけで schema / wrapper / gate / approval layer / ledger を新設しないでください。具体的 failure class を固定する最小恒久対策を優先してください。

    Not authorized

    以下は承認していません。

    Fresh-state first

    過去 transcript、上記で記載した SHA、過去の Skill procedure を current fact とみなさないでください。

    最初に fresh に確認してください。

    1. 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 current body / comments / state / labels / updatedAt
    2. latest comment 5964870175 の full body、author association、identity
    3. original anchor 5963286403
    4. current main HEAD
    5. 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 を参照する existing PR / branch の有無
    6. 実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 の Allowed Paths と overlap する current OPEN PR / Issue
    7. current .claude/skills/issue-refinement-loop/SKILL.md
    8. current .claude/skills/impl-review-loop/SKILL.md
    9. 両 Skill が current HEAD で参照する relevant references / scripts / Agents / SSOT

    現時点の外部観測では #2878 の PR / branch は見つかっていませんが、これは開始時に必ず再確認してください。存在していれば duplicate を作らず再利用してください。

    Phase A — refinement recovery

    latest OWNER termination comment 5964870175 を今回の operator-selected human-context anchor として current issue-refinement-loop を実行してください。

    original anchor 5963286403 は、既に disposition 済みの背景 technical evidence として利用してください。latest termination comment の未反映 findings が今回の主要修復対象です。

    必ず解消する残 findings

    latest comment に記録された以下 5 件を current main で independently validate し、まだ成立するものを Issue body に反映してください。

    1. closing keyword grammar の過剰 fail-closed

    現契約の「closing keyword の後が解釈不能なら fail_closed」が通常 prose:

    • fixes the typo
    • resolved by ...

    等まで誤検出しないようにする。

    GitHub closing reference の候補とするのは、current external semantics と repository contract を確認したうえで、keyword 直後が actual issue target grammar(例: #N / <owner>/<repo>#N / issue URL)に入る場合へ bounded に限定することを検討してください。

    通常 prose が reference と誤認されない negative regression を AC / VC に固定してください。

    外部仕様の判断が必要なら current GitHub official docs を fresh に確認してください。

    2. reference facts / evaluator wire contract を固定

    以下を prose ambiguity のまま実装へ渡さないでください。

    • facts JSON の exact keys / type / required fields
    • evaluator output の exact keys / enum
    • pr_body_sha256 は evaluator が実際に評価した PR body bytesから算出すること
    • --evaluate-reference-policy と既存 --body-file / --linked-issue CLI contract の関係
    • A1 comment URL と PR 本文 Reference-Decision: URL の exact identity binding
    • updated_at を authority / freshness に使うのか、diagnostic に限定するのか

    既存 schema / parser / CLI convention を再利用できるなら新 schema は作らず、current architecture と最小整合する形を選んでください。

    3. cleanup_exec._verify_linked_issue との境界

    current main で、Refs-bound PR に対して cleanup_exec._verify_linked_issue が closingIssuesReferences または research fallback を要求し、linked_issue_number を渡すと LINKED_ISSUE_MISMATCH になる failure class を再確認してください。

    #2878 の Outcome が本当にどこまでを所有するかを明確にしてください。

    候補は current architecture に基づいて決めること:

    大掛かりな新 harness は追加しないでください。

    closing-relation 非依存の cleanup_exec 認可そのものが独立 Outcome なら #2878 に無理に混ぜず、既存 Issue を dedupe した上で follow-up Issue として materialize してください。

    4. AC7 parity の wire を固定

    producer / consumer parity regression が曖昧にならないよう、

    • non_closing_authority が snapshot のどこに存在するか
    • producer output → snapshot → adapter input の mapping
    • fixture の accept / reject の対応

    を contract 上 exact にしてください。

    5. A2 parser と複数 A1 decision 行

    A2 Runtime Verification section をどの existing parser / SSOT で読むかを決め、独自の脆い regex 再実装を避けてください。

    また、PR 本文に複数の Reference-Decision: 行が存在する場合を明示し、ambiguous A1 は fail closed とするのか等を exact regression として固定してください。

    Phase A completion gate

    以下をすべて満たすまで implementation を開始しないでください。

    • 5 findings がすべて disposition 済み
    • current Issue body が self-consistent
    • Outcome / scope / AC / VC / Allowed Paths / Runtime Verification が実装可能
    • static readiness が go
    • deterministic review が approve
    • applicable な Step 2.5 semantic design review が clear / joined approve
    • fresh GitHub body readback / digest が一致
    • canonical issue-refinement-loop: approved termination が publish 済み
    • dispatch した全 SubAgent の terminal result を回収済み

    normal な semantic needs-fix は新 invocation の canonical iteration budget 内で自動修復してください。

    max_iterations を迂回したり手動で approve を捏造してはいけません。再び canonical upper bound に到達した場合は Phase B に進まず停止してください。

    Transition from Phase A to Phase B

    Phase A が approved になったら、refinement Skill が implementation を自動起動しないことは正しい挙動です。

    その termination が完了した後、このユーザー prompt が既に implementation を明示的に依頼していることを authority として、root/main thread から current impl-review-loop の正式 entry を fresh に開始してください。

    過去の contract snapshot を盲目的に再利用せず、current Issue body / current main / current PR state をもう一度取得してください。

    Phase B — current impl-review-loop

    current .claude/skills/impl-review-loop/SKILL.md を正本として従ってください。古い transcript の Step 名、command、flag、agent role を優先しないでください。

    特に current contract の Root-Owned Synchronous Entry Transition を守り、内部 step を ad hoc に飛び越えて worker を直接開始しないでください。

    概念的には:

    fresh intake → preparation / landing disposition → Step 1 implementation → Step 2 verification → Step 4 PR review → Step 5 routing → fix/retest/rereview → draft_pr_ready

    まで継続します。

    Preparation

    worker / new worktree / new PR を作る前に current canonical preparation を完了してください。

    • live Issue body と comment state
    • fresh main HEAD
    • existing implementation branch / worktree / PR
    • current scope coverage / landing disposition
    • current contract snapshot
    • main drift
    • Allowed Paths
    • overlap PR / Issue
    • existing partial / landed implementation evidence

    既存 PR が存在すれば current canonical existing_pr_resume 等の disposition に従って再利用し、duplicate PR を作らないでください。

    実装済み / already-satisfied が fresh deterministic evidence で確定した場合は current Skill の early-exit contract に従い、不要な implementation delta を作らないでください。

    SubAgent lifecycle

    必要な SubAgent を積極的に利用してください。

    少なくとも current Skill が定義する役割:

    • implementation-worker
    • test-runner
    • pr-reviewer

    を適切な phase で使用してください。

    各 SubAgent には親会話の暗黙 context に依存させず、最低限:

    • task
    • target Issue / PR / exact HEAD
    • authority / current contract
    • Allowed Paths
    • constraints
    • relevant evidence
    • expected structured output

    を明示してください。

    SubAgent を dispatch しただけで phase 完了扱いにしてはいけません。

    dependency のある各 phase は、SubAgent の terminal result / background completion notification / structured final output を実際に回収してから downstream phase へ進んでください。

    independent な read-only investigation は必要なら並列化して構いません。

    nested delegation は current Agent / Skill contract が許可する場合のみ行ってください。

    Implementation

    Issue #2878 の current approved contract を実装してください。

    implementation 中に Allowed Paths 外の変更が本当に不可欠だと判明した場合、勝手に scope 外を編集しないでください。current repository-native contract update / refinement route へ戻し、必要な scope adjustment を canonical に materialize してから fresh implementation entry へ戻ってください。

    Verification

    Issue body の Verification Commands を current approved body から fresh に取得して実行してください。

    • AC ごとの focused regression
    • required baseline-expect semantics
    • standard typecheck / lint / tests / build
    • current model-routing gate 等、Issue が要求する quality gates
    • required CI
    • runtime AC / runtime_assertion_bindings

    を current contract に従って検証してください。

    Runtime Verification AC9 等で環境が unavailable / SKIP になった場合は、SKIP を PASS に昇格しないでください。current runtime verification policy に従い exact evidence / reason を保持してください。

    test が green でも destination behavior を検証していない false-green でないことを Step 4 reviewer が独立確認できる状態にしてください。

    PR

    current open-pr contract を使用してください。

    PR を作成または更新したら、current HEAD と Issue contract を bind して verification / review を実行してください。

    Review / fix loop

    Step 4 の fresh pr-reviewer / pr-review-judge review を必ず実施してください。

    REQUEST_CHANGES が返った場合:

    1. finding を evidence と照合
    2. genuine finding は fix_delta として implementation-worker へ渡す
    3. 修正
    4. focused tests
    5. required verification
    6. push
    7. fresh PR HEAD を再取得
    8. fresh review

    まで自動継続してください。

    reviewer が返す自己申告だけで merge readiness を決めず、current impl-review-loop control-plane が所有する live mergeability / CI / HEAD routing に従ってください。

    reviewed_head_sha が stale なら current head で再 review。
    branch が BEHIND なら current canonical update-branch route。
    修正可能 CI failure は原因を調査して修正または bounded rerun。
    actual Git conflict は current conflict runbook に従ってください。

    Completion target

    以下の current impl-review-loop 正常終了条件まで続行してください。

    • reviewer verdict: APPROVE
    • blockers: []
    • current-head review
    • required verification / CI が contract を満たす
    • live mergeability が current Skill の approved condition を満たす
    • IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready

    draft_pr_ready に到達したら停止してください。

    以下は実行しないでください。

    Stop / escalation boundary

    次だけを genuine stop 候補として扱ってください。

    • destructive operation が必要
    • secret / credential / permission mutation が必要
    • force push / history rewrite が必要
    • repository contract が genuine human_judgment_required を返した
    • Phase A が canonical max_iterations に再到達
    • irreconcilable scope conflict
    • authority 外変更が不可避で canonical scope update でも解けない
    • evidence integrity を維持できない
    • required runtime target が利用不能で current contract が human escalation を要求する
    • ユーザーの明示停止

    通常の test failure、review finding、REQUEST_CHANGES、stale HEAD、fixable CI failure、main drift は停止理由にしないでください。

    Final report

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

    Refinement recovery

    • fresh main SHA
    • consumed anchor URL / trusted status
    • latest 5 findings の disposition
    • final approved Issue body SHA / readback status
    • deterministic review verdict
    • semantic review verdict
    • joined verdict
    • approved termination comment URL

    Implementation

    • implementation worktree / branch
    • PR number / URL / exact final HEAD
      -主要 implementation delta
    • AC / VC results
    • runtime verification result
    • required CI status
    • final PR review verdict
    • live mergeability
    • IMPL_REVIEW_LOOP_RESULT_V1 status

    Recurrence prevention

    Remaining state

    調査・提案だけで終わらず、canonical workflow が許す範囲で実作業を完遂してください。

    この形なら、現在の max_iterations_exceeded を無視して false-start することを避けつつ、refinement が通った後は追加の人間承認を挟まず、そのまま正式な impl-review-loop entry から draft_pr_ready まで進められます。

  6. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

    前回 human_escalation の残 5 findings の disposition

    1. closing keyword grammar: keyword 直後が #N / <owner>/<repo>#N / issue URL の場合だけ reference 候補とし、通常 prose は無視する定義へ限定。negative fixture を AC2 に追加
    2. facts / evaluator wire: facts JSON と output の exact keys / enum、pr_body_sha256 は --body-file の bytes から算出、既存 CLI 引数との関係、A1 URL の exact 一致、updated_at は不使用と固定
    3. cleanup_exec._verify_linked_issue: fresh main で成立を再確認。Outcome を Task Context cleanup binding に限定し、closing 非依存の削除認可は follow-up 実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891(dedupe 済み・実装: PR Closes/Refs 選択と post-merge OPEN close gate を整合する #2878 に blocked-by)へ分離
    4. AC7 parity: non_closing_authority は snapshot の top-level key(pullRequest の兄弟)、producer 引数との写像と accept / reject 写像、allow_non_closing keyword-only 引数を固定
    5. A2 parser: prose_boundary_policy.extract_level2_section_with_bounds を再利用し独自 regex を作らない。複数 Reference-Decision: 行は a1_decision_ambiguous で fail_closed

    追加で semantic review の指摘(CLOSED の写像と notes-only、lint mode の欠落入力、fence 内 closing の decision 別扱い、AC9 を ordered-marker と fixture 用 output schema で実体化、repo 比較の case 扱い)も反映済み。

    LOOP_HANDOFF_RESULT_V1:
      status: refinement_approved
      routing_action: none
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: "none(run_contract_review_once execute の go を live body SHA に対して確認。snapshot comment は impl-review-loop preparation が materialize)"
        generated_at: 2026-10-03T03:32:13Z
        body_sha256: feb0cfa81ea7254649c4ca696b79259148ba29ddac60d106b8da27dc48afdf3b
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "label は変更していない"
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: 2026-10-03T03:32:13Z
      checked_body_sha256: feb0cfa81ea7254649c4ca696b79259148ba29ddac60d106b8da27dc48afdf3b
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  7. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  8. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-10-03T04:34:48Z)

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