Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "approved scope reframe から生成された Issue rewrite が完全な body rewrite operation を必要とする場合に、no-progress な contract_update 再試行ではなく issue_editor_required へ route することで #1877/PR #1884 が実装した trusted anchor patch plan consumer の regression を塞ぐ"
change_kind: codeParent Issue
none(単独改善)
Parent Goal Ref
- Goal: approved scope reframe(trusted anchor)を受けたとき、
operations[]が空で完全な body rewrite が必要なケースをcontract_updateの no-progress ループに落とさず、issue-editor 経路へ確実に route する。 - Desired Destination:
.claude/skills/issue-refinement-loopの rewrite router(decide_rewrite_route.py/route_after_rewrite.py/plan_refinement_loop.py)。
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.pyの rewrite route 決定ロジックに、approved scope reframe かつoperations[]空の場合のissue_editor_required分岐を追加.claude/skills/issue-refinement-loop/scripts/decide_rewrite_route.pyに empty-operations fingerprint による no-progress 再試行防止を追加.claude/skills/issue-refinement-loop/scripts/route_after_rewrite.pyの readback 済み判定に、body/title readback と fresh review/preflight 完了までのimplementation_allowed=false維持を追加- 上記変更に対応する
.claude/skills/issue-refinement-loop/tests/配下の regression テスト追加
Remaining Parent Gaps
なし
Outcome
trusted ANCHOR_SCOPE_REFRAME_V1 が承認され非空の allowed_path_deltas が存在する一方、既存 CONTRACT_PATCH_PLAN_V1.operations[] ではその変更を materialize できない場合に、canonical production path(contract_update.run.with_human_context → run_refinement_preflight.py → consume_trusted_anchor_contract_patch_plan())から、no-progress な contract update を再試行せず、機械可読な NEXT_ACTION: issue_editor_required へ実際に到達できる状態。unit helper 単体のテストではなく、canonical command から consumer までの process-boundary E2E で証明されていること。issue-editor 経路への handoff 後は、fresh readback・fresh review・fresh readiness ゲートが完了するまで implementation が許可されない。
In Scope
- trusted structured scope reframe の validated classification と patch plan を、canonical consumer 境界(
consume_trusted_anchor_contract_patch_plan())で実際に join する - empty
operations[]単独ではissue_editor_requiredに昇格させず、patch/proven_no_change/full_rewrite_required/invalidの4分類(disposition)を transaction-local に区別する full_rewrite_requireddisposition では contract-update mutation を一切実行せず、wrapper(run_refinement_preflight.pyの post-update handoff projection)まで route を実際に伝播させ、stdout のNEXT_ACTIONと result artifactnext_actionをissue_editor_requiredにする- 同一 disposition の再実行(replay)で contract-update mutation・scope-reframe comment 投稿が共に 0 件であることを保証する
route_after_rewrite.pyの post-update gate(body/title readback・fresh review/preflight完了までのimplementation_allowed相当ゲート)を、既存run_refinement_preflight.py::_bounded_contract_update_handoff()の既存 gate と統合し、二重の routing plane を作らないSKILL.mdの canonical orchestration にNEXT_ACTION: issue_editor_required受信時の handoff 手順(contract_update.run.with_human_context を再実行しない・scope-reframe comment を再投稿しない・既存 issue-editor/edit-issue 経路へ委譲する)を追記する- production caller chain(canonical command → wrapper → classification → consumer → classifier → NEXT_ACTION projection → SKILL handoff)を対象にした process-boundary E2E regression テストを追加する(positive fixture 1件 + negative regression 7件、詳細は Verification Commands 参照)
- 既存
#1835/#1877(PR fix(refinement): trusted anchor iteration-zero を実装 (#1877) #1884) /#1952(test_issue_1952_trusted_directive_regression.py)regression を回帰なく維持する
Out of Scope
CONTRACT_PATCH_PLAN_V1schema へのallowed_path_deltasフィールド追加(OWNER decision により不採用)- generic な patch plan consumer 全体の再設計(
#1877の既存実装を維持する。境界拡張のみ許可) - issue-editor の candidate body 生成ロジック自体の変更(既存
edit-issueskill の責務) #2040(Runtime Verification Applicability の fail-closed 統一)のスコープ- 新しい command-policy / privileged-executor surface の新設
- 新しい persistent schema・artifact family・receipt・publisher の新設
- 別 Issue への分割(OWNER decision により本 Issue で完結させる)
Acceptance Criteria
- AC1:
full_rewrite_requireddisposition が検出されたとき、canonical production path(contract_update.run.with_human_context経由のrun_refinement_preflight.py→consume_trusted_anchor_contract_patch_plan())から stdout にNEXT_ACTION: issue_editor_requiredが出力され、result artifact のnext_actionも同値であることが process-boundary E2E テストで証明される - AC2: 同一 disposition の replay で contract-update mutation が発行されない(
apply_transaction未呼出・Issue write count 0 がテストで検証される) - AC3: 同一 transition で scope-reframe comment が重複投稿されない(
full_rewrite_required判定時は新規 comment を作成しない設計とし、comment publish count 0 がテストで検証される) - AC4: issue-editor mutation 後、fresh readback・fresh review・fresh readiness ゲートが完了するまで implementation が許可されないことが、既存
_bounded_contract_update_handoff()の post-update gate 再利用により証明される - AC5: 既存
#1835fixture・#1877regression fixture(test_issue_1952_trusted_directive_regression.py含む)が回帰なく PASS する - AC6: production-path E2E(positive fixture 1件: trusted anchor + non-empty allowed_path_deltas + empty operations → issue_editor_required、negative regression 7件: non-empty operations / 未承認reframe / 既に反映済みdelta / operations型不正 / allowed_path_deltas不正 / anchor identity drift / replay の各ケース)が追加され全て PASS する
Verification Commands
$ rg -n "full_rewrite_required" .claude/skills/issue-refinement-loop/scripts/decide_rewrite_route.py # AC1
$ rg -n "issue_editor_required" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py # AC1
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q # AC2
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q # AC3
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q # AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_route_after_rewrite.py -q # AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_issue_1952_trusted_directive_regression.py -q # AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -qAllowed Paths
- .claude/skills/issue-refinement-loop/SKILL.md
- .claude/skills/issue-refinement-loop/references/loop-state.md
- .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
- .claude/skills/issue-refinement-loop/scripts/decide_rewrite_route.py
- .claude/skills/issue-refinement-loop/scripts/route_after_rewrite.py
- .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
- .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json
- .claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json
- .claude/skills/issue-refinement-loop/tests/test_rewrite_router.py
- .claude/skills/issue-refinement-loop/tests/test_route_after_rewrite.py
- .claude/skills/issue-refinement-loop/tests/test_scope_only_reframe_route.py
- .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
- .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
- .claude/skills/issue-refinement-loop/tests/test_trusted_anchor_iteration_zero.py
- scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Required Design References
- docs/dev/agent-skill-boundaries.md
Scope Delta(任意)
OWNER decision(#2048 (comment) への回答, 2026-08-09)により Allowed Paths を拡張。理由: PR #2057 iteration1/iteration2 で pr-reviewer が2回連続で同一の構造的原因(decide_scope_reframe_contract_route() が唯一の production 呼び出し元 consume_trusted_anchor_contract_patch_plan()〈run_refinement_preflight.py、旧 Allowed Paths外〉から到達不能)を指摘。OWNER が解決策 (a′)(run_refinement_preflight.py を Allowed Paths に追加、CONTRACT_PATCH_PLAN_V1 schema 変更〈案(b)〉は不採用、別Issue分割〈案(c)〉も不採用)を承認。
追加 Scope Delta(2026-08-09、iteration4): OWNER の REQUEST_CHANGES(PR #2057 コメント https://github.com/squne121/loop-protocol/pull/2057#issuecomment-5231808692)が P0-3 として要求した「真の process-boundary E2E」は、#1877 / PR #1884 が実装した既存の subprocess-boundary test harness(_install_real_contract_update_fixture() 等)を再利用する必要があり、そのフィクスチャは scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py に存在する。既存 harness を再利用しつつ registry → policy → privileged executor subprocess → production wrapper → production classifier → fake gh の実 process boundary を通す E2E を追加するには、このファイルへのテスト追加が必須であるため Allowed Paths に追加する(test-only, 既存ファイルへの追記、schema/production code 変更なし)。
Notes for Reviewer
これは #1877(CLOSED, PR #1884 で trusted anchor patch plan consumer を実装)の regression follow-up として扱う。#2040(OPEN, Runtime Verification Applicability の fail-closed 統一)とはスコープが異なるため混載しない。
これは #1877(CLOSED, PR #1884)の regression follow-up であり、かつ本 Issue 自身の初回実装(PR #2057 iteration1/2)が production 到達可能性を欠いていた反省を踏まえた Scope Delta 版。reviewer は production caller chain(canonical command → wrapper → classification → consumer → classifier → NEXT_ACTION projection → SKILL handoff)が current head に実在することを rg / import tracing で必ず確認すること。unit helper 単体のテスト PASS のみで AC 充足と判定しない。
Runtime Verification Applicability
本 Issue の変更対象はワークフロー文書・スクリプトのみです。ゲームの実行時動作には影響しません。
decision: not_applicable
reason: "Workflow documentation and script changes only. No runtime game behavior changed."
Activity
squne121 commentedon Aug 9, 2026
判定
総評
#2048 が扱おうとしている不具合自体は実在します。trusted な scope reframe が承認されても、完全な Issue 本文 rewrite を表現する patch operation が生成されなければ、現行の contract-update phase は
writes: 0の fail-closed 終了になり、同じ入力を再試行しても進展しません。しかし、現行契約のまま実装すると、実際に失敗している production consumer ではなく、別系統の rewrite router に文字列と fingerprint を追加するだけになる可能性が高いです。#2048 は
decide_rewrite_route.pyとroute_after_rewrite.pyを主要変更点にしていますが、canonical Skill はdecide_next_loop_action.pyを next-action SSOT とし、実際の missing patch-plan failure はrun_refinement_preflight.pyのconsume_contract_patch_plan分岐で生成されています。#2048 の Allowed Paths は、この二つの正規変更点を含んでいません。さらに、PR #1884 でも「callback テストでは成功するが、通常の
issue-refinement-loopから consumer を起動できない」という、ほぼ同型の P0 が実際に発生しています。#2048 は regression follow-up を名乗りながら、その事故の原因だった canonical call-path 非接続を再び契約へ持ち込んでいます。Merge blockers
P0-1 — 修正対象が canonical control plane ではない
レビュー時点の正規経路は概ね次です。
一方、#2048 が中心に据えている経路は次です。
decide_rewrite_route.pyの参照をコード検索した範囲では、本体と単体テストしか確認できません。canonical Skill はこの router ではなくdecide_next_loop_action.pyを使用しています。したがって、AC1 の
を満たしても、production の
contract_update再試行を止めた証明にはなりません。必須修正
issue_editor_requiredの producer と consumer を、少なくとも次へ移してください。producer:
scope_signal_delta.pyまたはplan_refinement_loop.pycanonical router:
decide_next_loop_action.pycontrolled phase consumer:
run_refinement_preflight.pyorchestration contract:
SKILL.md必要な場合のみ
command_registry.pydecide_rewrite_route.py/route_after_rewrite.pyは、正規経路へ昇格させて既存 route を撤去するのでなければ、#2048 の主実装対象から外すべきです。二つの routing plane を残す設計は避ける必要があります。P0-2 —
operations == []は full rewrite の判定根拠にならない現在の
CONTRACT_PATCH_PLAN_V1はoperationsを必須配列としていますが、minItemsを指定していません。したがってスキーマ上、空配列は正規入力です。JSON Schema でも、長さ制約を指定しない空配列は有効であり、非空を要求するにはminItemsが必要です。 (JSON Schema)空の
operationsは少なくとも次の状態を区別できません。#2048 の AC1 は、これらをすべて
issue_editor_requiredに吸収する危険があります。特に C と E を issue-editor に流すと、planner failure を自動 rewrite に昇格させる fail-open になります。必須修正
空配列を oracle にせず、明示的な排他的 disposition を producer が出してください。
最低限の不変条件は次です。
JSON Schema では
oneOfによって「必ず一つだけの分岐が成立する」契約を表現できます。 (JSON Schema)P0-3 —
issue_editor_requiredが end-to-end の型付き契約になっていない現行の
SCOPE_DELTA_AUTHORITY_V1.route.actionは次の三値です。issue_editor_requiredは存在しません。next_stepもrerun_refinement_after_contract_updateまたはnullに限定されています。また、
refinement_preflight_result_v1のcontract_update.statusは次の四値です。ここにも「正常な非失敗として issue-editor へ引き渡した」という状態がありません。
next_action自体は自由文字列ですが、自由文字列だけでは producer・router・consumer 間の enum parity を検証できません。#2048 のままでは、次のような分裂が起こり得ます。
必須修正
次を同じ変更単位で更新してください。
authority/materialization schema
planner producer
decide_next_loop_action.pypreflight result の typed handoff
SKILL の action table
issue-editor consumer
unknown action の fail-closed test
#1952 では、issue-editor の authority を「intent → role → Skill → transaction input → controlled executor → mutation → postcondition readback → evidence」の chain として検証しています。#2048 も単に action 名を返すのではなく、この既存 chain へ接続しなければなりません。
P0-4 — AC2/AC3 の idempotency 保証が現在の入力では成立しない
route_after_rewrite.pyは fingerprint を永続 state に保存しています。したがって「完全にメモリ内だけ」という問題ではありません。しかし、その fingerprint は checker のreason_codesとrewrite_constraintsから構成され、次を束縛していません。repository
issue number
anchor comment ID
anchor body SHA-256
anchor trust / author association
base title SHA-256
base body SHA-256
updatedAtmaterialization disposition
planner/schema version
また、同 wrapper は Issue body を取得しますが、title、anchor comment、patch operations を入力として持ちません。したがって、#2048 が求める「同じ anchor / body SHA / empty operations fingerprint」をこのファイル単独で判定できません。
推奨 fingerprint は、例えば次の canonical object から生成します。
永続的または実装言語横断の fingerprint とするなら、単なる実装依存の JSON dump ではなく、RFC 8785 JCS またはリポジトリで同等に固定した canonicalization 契約を使うべきです。RFC 8785 は、JSON を hash/signature 用に再現可能な表現へ正規化する規則を定義しています。 (RFC Editor)
コメント重複防止
AC3 の「同じ scope reframe comment を重複投稿しない」も ownership が未定義です。
どの script が投稿するのか
どの marker を検索するのか
全ページを検索するのか
並行 writer をどう直列化するのか
create 後の readback を行うのか
がありません。
GitHub の Issue comment 一覧はページングされ、既定件数だけを読んだ場合は古い marker を見落とします。全ページ取得には pagination link を処理する必要があります。 (GitHub Docs)
また、公式の comment create API の文書化された入力は本文が中心で、利用者が指定する idempotency key は確認できません。したがって、これは文書からの推論ですが、独立 writer 間での unconditional exactly-once を API 任せにはできません。GitHub も mutative request の直列化と間隔確保を推奨しています。 (GitHub Docs)
最小設計は、この transition ではコメントを投稿しないことです。typed preflight handoff だけで十分です。コメントが必要なら、次を AC に固定してください。
同一 canonical writer の replay に限って duplicate 0 を保証
P0-5 — AC4 の readback と
implementation_allowedを誤った component に所有させている#2048 は
route_after_rewrite.pyに対し、を要求しています。
しかし現行
route_after_rewrite.pyは、body fetch、checker 実行、rewrite state 作成、rewrite router 呼び出しを行う wrapper です。title、anchor identity、transaction result、fresh preflight result を入力に持たず、RouteResult にもimplementation_allowedはありません。一方、実際の controlled consumer は既に次を担当しています。
これは
run_refinement_preflight.pyとrun_trusted_anchor_iteration_zero()側の責務です。したがって
implementation_allowedは別 router で再計算せず、controlled consumer の最終結果からのみ導出すべきです。fresh check の単なる文字列
passでは不十分です。少なくとも final title/body SHA、IssueupdatedAt、tested main SHA を同じ handoff に束縛してください。P0-6 — Allowed Paths が実装に必要な正本を含まず、Stop Conditions と矛盾する
現行 Allowed Paths には、少なくとも以下が不足しています。
逆に、
decide_rewrite_route.pyに新しい state field を追加するなら、strictadditionalProperties: falseのloop_rewrite_router_state_v1.jsonも変更が必要ですが、現行 Allowed Paths にありません。#2048 の Stop Conditions は Allowed Paths 外の変更が必要なら停止するとしています。よって、現契約のまま正規実装へ着手すると Stop Condition に直ちに該当します。
P1 findings
P1-1 — Verification Commands が挙動を証明していない
次の VC は source-text assertion または file-existence assertion にすぎません。
これらが PASS しても、次は一切証明されません。
canonical router が action を consume した
contract-update command が発行されなかった
issue-editor が呼ばれた
duplicate comment が投稿されなかった
title/body readback が実行された
fresh checks が final body に束縛された
replay が別プロセスでも収束した
PR #1884 が callback/unit test の成功だけでは canonical path 到達を証明できなかったことを踏まえ、process-boundary E2E が必須です。
P1-2 — 必須の adversarial matrix が不足している
最低限、次のケースを同じ producer→router→consumer fixture matrix で検証してください。
入力 | 正しい route
-- | --
trusted directive、非空 operations | contract_update_required
trusted directive、candidate already satisfied | proven_no_change
trusted scope reframe、明示的 full rewrite disposition、空 operations | issue_editor_required
空 operations、disposition 欠落 | fail-closed
空 operations、unsupported directive | fail-closed
untrusted / edited anchor | fail-closed
anchor ID は同じだが body hash が変化 | fingerprint 変更、旧 handoff 拒否
body は同じだが title が変化 | fingerprint 変更、re-read/rebase
同じ入力を別プロセスで再実行 | 同一 action、contract-update invocation 0
final body は一致、title 不一致 | blocked
fresh review が旧 body SHA を参照 | blocked
unknown action enum | blocked
concurrent duplicate-comment writer | serialized または一方だけ作成
P1-3 —
#1835 fixtureと#1877 regressionの要求が曖昧#1835 は Codex Multi-Agent V2 config と concurrency/max-depth migration を扱う Issue です。#2048 の routing defect と直接関係するのは、そこで利用されている fixture の特定 invariant だけと考えられます。単に「#1835 fixture を維持」とすると、何を保護しているのか不明です。
次のように具体化してください。
#1952:
issue-creator と issue-editor の role separation、
issue-editor が直接 GitHub mutation せず controlled executor を使う invariant
#1835 fixture:
実際に本 route が参照する fixture field/schema の後方互換性だけ
P1-4 — Runtime Verification Applicability がない
#2048 は
issue_kind: implementationですが、本文に## Runtime Verification Applicabilityがありません。直近の #2040 レビューでも、implementation Issue にこの判断を明示することが要求されています。今回のスコープを「Python producer/router/consumer と fake GitHub を使った process-boundary E2E」に限定するなら、次が妥当です。
squne121 commentedon Aug 9, 2026
issue-refinement-loop 終了報告
結果: approved(1 iteration、review-issue VERDICT: approve、validator: valid)
実施内容
run_refinement_preflight.pyが deterministic repair 候補(VC の AC6 コマンド直前に# baseline-expect: failannotation 挿入)を検出。auto-apply consumer が存在しないため一旦停止し、人間承認を得た上でissue-editor経由で本文へ適用(BODY_HASH:sha256:f76950cc...。additive に## Runtime Verification Applicabilityセクションも hygiene autofix で補完)codebase-investigatorにより repo fact claims(対象ファイル存在、decide_rewrite_route.pyにcontract_updateは存在するがissue_editor_requiredは未実装、#1877regression fixtures は存在し PASS、test_scope_only_reframe_route.pyは未作成、VC baseline は全て fail)を全て confirmedissue-reviewerによるレビュー: C1-C11 全 pass、VERDICT: approve、validate_review_compact_output.pyで valid 判定済みscope_delta_decision.status: fail_closed(scope reframe 対象ではない通常コメント)、scope_signal_guard.triggered: false最終状態
sha256:3129a1c163f8a1d358ef60ef20cc1860599e017e93bb3fe88312ce8dacc3940cdecide_next_loop_action.py→STATUS: pass/NEXT_ACTION: proceed_to_step_4_5parent_issue: none、単独 implementation issue)squne121 commentedon Aug 9, 2026
implement-issue: 実装完了 (2026-08-09)
.claude/worktrees/issue-2048-scope-reframe-empty-ops-routeworktree-issue-2048-scope-reframe-empty-ops-route461a5716edbc49d6e086ad17078ed88df4f2f30c.claude/skills/issue-refinement-loop/tests/全体 1236 pass、ruff checkpass)fix: #2048 scope reframe route を production 経路(scope_signal_delta / p…
squne121 commentedon Aug 9, 2026
impl-review-loop 停止報告(Stop Condition 該当・人間判断待ち)
2回のイテレーションでいずれも pr-review-judge から REQUEST_CHANGES を受け、両方とも同一の構造的原因でした:
control-plane(Opus)が独立に追跡した結果、以下が判明しました:
consume_trusted_anchor_contract_patch_plan()の唯一の呼び出し元はrun_refinement_preflight.py:3189の1箇所のみで、この関数自体・呼び出し元ともに Allowed Paths 外run_trusted_anchor_iteration_zero()に渡されるanchor引数は生の GitHub コメント payload(dict(comment_payload))であり、scope reframe classification 結果(allowed_path_deltasを含む)を含まないpatch_plan引数(CONTRACT_PATCH_PLAN_V1)は固定スキーマ(schema_version/target_issue_number/base_issue_body_sha256/source_evidence/operations/forbidden/required_next_step)でallowed_path_deltasフィールドを持たないallowed_path_deltasを実際に計算しているのは_classify_anchor_scope_reframe()(同じくrun_refinement_preflight.py内、Allowed Paths 外)で、その結果は現在run_trusted_anchor_iteration_zero()に渡されるどの引数にも伝播していないつまり、Issue #2048 の Allowed Paths 内だけで完結する形で、新規ロジックを実際の production 実行経路から到達可能にする方法が存在しません。かつ Issue の Out of Scope は明示的に「generic な patch plan consumer の再設計(
#1877の既存実装を維持する)」を除外しており、CONTRACT_PATCH_PLAN_V1スキーマへのフィールド追加も Stop Condition(固定契約のキー集合・スキーマ変更)に抵触します。これは Issue #2048 自身の Stop Condition「Allowed Paths 外の変更が必要と判明した場合」に該当すると判断し、impl-review-loop をここで停止します(
termination_reason: human_escalation)。想定される解決策(人間判断が必要)
run_refinement_preflight.pyのconsume_trusted_anchor_contract_patch_plan()/ その呼び出し元を Allowed Paths に追加し、allowed_path_deltasを実際に転送する配線を許可する(Scope Delta)CONTRACT_PATCH_PLAN_V1スキーマにallowed_path_deltas相当のフィールドを追加する契約変更を承認する現在の PR #2057(head
3bd7ad7697d0b9d2ed76642ca6c1b4e8347d2ec3)はこの状態で Draft のまま保持します。AC1-AC6 のユニットテストレベルの検証は全て PASS していますが、production 到達可能性は未証明です。squne121 commentedon Aug 9, 2026
結論
推奨は (a) の修正版「(a′)」です。 #2048 自体を Scope Delta で更新し、
run_refinement_preflight.pyと production-path E2E テストを Allowed Paths に追加したうえで、既存 PR #2057 をそのまま継続するのが最短です。CONTRACT_PATCH_PLAN_V1へのallowed_path_deltas追加は不要です。停止報告の「production caller に
allowed_path_deltasが届かない」という診断は正しい一方、現在の wrapper は structured anchor を_classify_anchor_scope_reframe()した結果をknown_context["scope_delta_decision"]に既に保存し、その context をconsume_trusted_anchor_contract_patch_plan()に渡しています。したがって、patch-plan schema を拡張せず、consumer 境界で既存の trusted context と patch plan を join できます。ANCHOR_SCOPE_REFRAME_V1自体もallowed_path_deltasを必須・1件以上として検証する strict schema です。ただし、単に
allowed_path_deltasをrun_trusted_anchor_iteration_zero()に渡すだけでは、まだ不十分です。現在の_bounded_contract_update_handoff()は consumer result からstatus/writes/iterations/final_readback/fresh_*だけを projection しており、PR #2057 が追加したrewrite_routeは落ちます。しかも post-update 6-gate が成立しなければfailedに変換されます。つまり「helper には到達したが orchestrator には届かない」という、#1877/PR #1884 と同型の事故をもう一段後ろで再発させます。敵対的レビュー
P0 — 現在の PR #2057 はまだ end-to-end で未実装です。 PR は Draft、head
3bd7ad…、9ファイル・+996/-3 行まで実装されていますが、停止コメントどおり production reachability は未証明です。 #1877/PR #1884 でも、callback/unit test では transaction が通る一方、通常のissue-refinement-loopから consumer を起動できない P0 が実際に発生し、最終的に canonicalcontract_updatephase を process-boundary E2E まで接続して解消しています。今回も同じ証明水準が必要です。P0 —
operations == []単独を full rewrite の oracle にしてはいけません。 現行CONTRACT_PATCH_PLAN_V1はoperationsを必須配列にはしていますがminItemsはなく、empty array は正規入力です。 JSON Schema でも空配列は追加の長さ制約がなければ有効です。(JSON Schema) したがってempty = full rewriteではなく、最低でも「trusted structured reframe」「非空のallowed_path_deltas」「operations が型として正しい空 list」「現在の Issue の Allowed Paths に少なくとも1つ approved delta が未反映」を同時に満たした場合だけissue_editor_requiredにしてください。既に全 delta が反映済みならno_change、型不正や binding 不一致なら fail-closed です。P0 — route は handoff projection より前に扱うべきです。 最小変更では
CONTRACT_PATCH_PLAN_V1やrefinement_preflight_result_v1.contract_updateの固定 enum を変更せず、consumer がfull_rewrite_requiredを返した時点で通常の_bounded_contract_update_handoff()を通さず、wrapper の既存 top-levelnext_actionをissue_editor_requiredに override するのが適切です。refinement_preflight_result_v1のnext_actionは現在 enum ではなく単なる string なので、キー集合を変えずにこの routing を表現できます。 このケースでは contract update 自体を実行していないため、無理にcontract_update.status=no_changeと偽装するより、optionalcontract_updatehandoff を出さない方が意味論も明確です。P1 —
plan_refinement_loop.pyとroute_after_rewrite.pyに routing plane を増やし過ぎています。 production wrapper は既に trusted classification をknown_context.scope_delta_decisionに置きますが、実 mutation はconsume_trusted_anchor_contract_patch_plan()からrun_trusted_anchor_iteration_zero()へ進みます。 一方、現行route_after_rewrite.pyの新 AC4 boolean より、既存_bounded_contract_update_handoff()の方が既に fresh preflight / review / readiness / Allowed Paths / permission profile / runtime evidence の6条件 conjunctionを production gate として持っています。 AC4 はこの既存 gate と issue-editor 後の readback を再利用し、孤立した新 boolean を production proof にしない方がよいです。P1 — AC3 のためだけのコメント dedupe machinery は削減候補です。 この transition 自体が新しい scope-reframe comment を投稿する必要はありません。authority は既存 trusted anchor です。GitHub の create-comment API には、文書化された入力上、呼び出し側が指定する idempotency key は見当たらず、これは文書からの推論ですが API 任せの exactly-once は期待すべきではありません。また GitHub は mutation を直列化することを推奨し、content creation の高速反復は secondary rate limit の対象になり得ます。([GitHub Docs]2) **「この transition ではコメントを投稿しない」**を AC3 の実装にすれば、fingerprint 永続化・pagination・publisher ownership を丸ごと避けられます。fingerprint を将来 durable/cross-language にするなら RFC 8785 のような明示的 canonicalization contract を採用する余地があります。([RFC Editor]3)
推奨する Scope Delta
#2048 の Allowed Paths に最低限
run_refinement_preflight.pyと production-wrapper E2E 用テスト(test_preflight_run_with_anchor.py、必要ならtest_trusted_anchor_iteration_zero.py)を追加してください。contract_patch_plan_v1.schema.jsonとcommand_registry.pyは追加不要です。既にcontract_update.run.with_human_contextは main-control-plane-only の canonical mutation phase として存在するため、それを再利用できます。#2048 の Out of Scope にある「generic patch-plan consumer の再設計」は維持できます。今回行うのは consumer の再設計ではなく、既に存在する trusted scope-decision と patch-plan を canonical transaction boundary で join し、patch では表現できない disposition を次 action に投影する狭い wiring 修正です。Issue 本文の Stop Condition は現在この変更を禁止しているため、実装より先に Issue contract を更新する必要があります。
以下をそのまま Claude Code / Codex CLI に渡すのがよいです。
Issue #2048 / Draft PR #2057 の実装を継続してください。
対象:
3bd7ad7697d0b9d2ed76642ca6c1b4e8347d2ec3OWNER decision:
CONTRACT_PATCH_PLAN_V1schema にallowed_path_deltasを追加する案 (b) は採用しない。最重要ゴール
trusted
ANCHOR_SCOPE_REFRAME_V1が承認され、非空のallowed_path_deltasが存在する一方、既存CONTRACT_PATCH_PLAN_V1.operations[]ではその変更を materialize できない場合に、contract_update.run.with_human_context→
run_refinement_preflight.py→
consume_trusted_anchor_contract_patch_plan()という canonical production path から、no-progress な contract update を再試行せず、機械可読な
NEXT_ACTION: issue_editor_requiredへ到達できるようにする。unit helper / callback test だけで「実装済み」と判定してはならない。
Step 1 — live contract と current main を再取得
最初に必ず以下を再取得する。
Issue 実装: 回帰: approved scope reframe に patch operations が無い場合、contract_update を再試行せず issue_editor_required へ route する #2048 本文・全コメント
comment #5230971281
PR fix: approved scope reframe の empty operations を issue_editor_required へ route (#2048) #2057 current head / diff / review comments / CI
current
mainIssue 実装: 修正: iteration 0 の trusted anchor を body-delta 非依存で contract update へ routing する #1877 / PR fix(refinement): trusted anchor iteration-zero を実装 (#1877) #1884 の production-wiring regression と最終解決
以下の current-main 実装:
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py.claude/skills/issue-refinement-loop/scripts/command_registry.py.claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py.claude/skills/issue-refinement-loop/schemas/contract_patch_plan_v1.schema.json.claude/skills/issue-refinement-loop/schemas/anchor_scope_reframe_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json.claude/skills/issue-refinement-loop/SKILL.mdPR branchが current main から遅れていれば、既存 PR を維持したまま安全に最新 main を取り込む。PRを作り直さない。
Step 2 — Issue #2048 の contract を先に Scope Delta 更新
実装前に Issue #2048 本文を controlled Issue edit で更新する。
Allowed Paths に最低限以下を追加する:
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py.claude/skills/issue-refinement-loop/tests/test_trusted_anchor_iteration_zero.py既存 Allowed Paths は必要なものを維持する。
以下は原則として追加しない:
contract_patch_plan_v1.schema.jsoncommand_registry.py既存
contract_update.run.with_human_contextを再利用できることを current main で確認すること。In Scope / Outcome / AC を、ファイル名ベースではなく production behavior ベースへ修正する。
最低限、次を契約化する:
operations[]単独ではissue_editor_requiredにしない。issue_editor_requiredでは contract-update mutation を実行しない。Step 3 — schema を変更せず既存 context を使用
CONTRACT_PATCH_PLAN_V1にallowed_path_deltasを追加しない。run_refinement_preflight.pyは既に structured anchor classification をknown_context["scope_delta_decision"]へ格納し、その
known_contextをconsume_trusted_anchor_contract_patch_plan()へ渡している。
この既存データフローを SSOT とする。
consumer 境界で以下を再検証する:
scope_delta_decisionが dictstatus == "approved_by_trusted_anchor"allowed_path_deltasが non-emptylist[str]contract_patch_plan["operations"]が list 型operationsを[]に coercion しないStep 4 — empty operations の曖昧性を解消
operations == []を full rewrite の十分条件にしない。最低でも次の disposition を transaction-local に区別する:
patch
proven_no_change
allowed_path_deltasが current Issue body に既にすべて反映済みfull_rewrite_required
allowed_path_deltasissue_editor_requiredinvalid
新しい persistent schema は作らず pure/transaction-local classifier として実装する。
既存 section parser / Allowed Paths parser が利用可能なら再利用し、文字列 grep だけで current-body satisfaction を判定しない。
Step 5 — canonical wrapper まで route を伝播
ここが今回の最重要修正。
現在の
_bounded_contract_update_handoff()はrewrite_routeを捨てるため、run_trusted_anchor_iteration_zero()にallowed_path_deltasを渡すだけでは完了としない。full_rewrite_requiredを検出した場合は通常の post-update handoff projection に入る前に分岐する。推奨:
_bounded_contract_update_handoff()の通常 success/failure 判定へ流さないnext_actionをissue_editor_requiredに設定する
NEXT_ACTION: issue_editor_requiredが出ること
next_actionも同値であることcontract_update.status=no_changeを full-rewrite-required の意味に流用しないrefinement_preflight_result_v1.contract_updateに新 field/status を追加しないnext_actionを利用できない明確な current-main 契約が見つかった場合のみ、その証拠を提示して別の最小 additive handoff を選ぶ。Step 6 — SKILL の canonical orchestration を更新
SKILL.mdの Step 0g / canonical stdout semantics を更新する。NEXT_ACTION: issue_editor_requiredを受信した場合:contract_update.run.with_human_contextを再実行しない新しい mutation command profile を作る前に、既存 issue-editor/edit-issue route を検索して再利用すること。
Step 7 — PR #2057 の過剰・非 canonical 実装を整理
PRに現在存在する以下を敵対的に再評価する:
plan_refinement_loop.pyのscope_delta_decision.operationsopt-in routeroute_after_rewrite.pyの独立implementation_alloweddecide_rewrite_route.pyに追加された大きな独立 routing planecanonical production path から消費されない route / boolean / state は残さない。
特に planner 側へ
operationsが production で供給されていないなら、「将来供給されるかもしれない optional wiring」を production proof として残さない。
同じ判断を planner / rewrite-router / contract-update wrapper の複数箇所で再実装しない。
pure classifier を1箇所に置き、canonical consumer がそれを呼ぶ構造を優先する。
Step 8 — AC3 は comment publisher を増やさず達成
この transition 自体では、新規 scope-reframe comment を投稿しない設計を優先する。
trusted anchor は既に存在するため、新たな comment は routing authority として不要。
したがって:
full_rewrite_required判定時に comment create を行わない他の既存 publisher が comment を出す場合は ownership を一つに限定し、同じ transition から二重 publish されないことを test する。
fingerprint を残す合理的理由がある場合は、
anchor URL + Issue body SHA だけでなく最低でも repo / issue / anchor comment id / anchor body SHA / base body SHA / disposition / reason / producer version を bind する。
durable/cross-language identity にする場合は canonical JSON contract を明示する。
Step 9 — production-path E2E を必須にする
helper直接呼び出しだけでは APPROVE しない。
#1877/PR #1884 と同じ失敗を防ぐため、canonical process path を通す regression test を追加する。
positive fixture:
ANCHOR_SCOPE_REFRAME_V1allowed_path_deltasCONTRACT_PATCH_PLAN_V1operations: []exact canonical entry:
contract_update.run.with_human_context→ command registry / policy / executor が既存ならそこを経由
→
run_refinement_preflight.py→ live-equivalent anchor classification
→ planner/patch plan
→
consume_trusted_anchor_contract_patch_plan→ disposition
→ wrapper projection
assert:
NEXT_ACTION: issue_editor_requirednext_action == "issue_editor_required"apply_transaction未呼び出しnegative regressions:
non-empty operations
→ existing contract_update behavior unchanged
empty operations + no approved structured scope reframe
→ issue_editor_required にしない
empty operations + approved reframe + all allowed_path_deltas already satisfied
→ proven no-change / existing safe route
malformed operations type
→ fail-closed
→ empty list に coercion しない
malformed/empty allowed_path_deltas
→ fail-closed
anchor URL / issue / repo / body hash / trust drift
→ fail-closed、write 0
replay of full_rewrite_required
→ contract-update mutation 0
→ comment 0
→ deterministic same route
既存 #1835 / #1877 / #1952 regressionsもすべて維持する。
Step 10 — AC4 は既存 post-update gate を再利用
route_after_rewrite.pyに孤立した boolean を追加しただけでは AC4 達成と判定しない。current
run_refinement_preflight.py::_bounded_contract_update_handoff()が持つ既存の post-update gateを確認する。
issue-editor mutation 後も同等以上の fresh evidence が canonical orchestration から要求されるようにする。
body/title readback が既存 issue-editor transaction で保証されているならそれを再利用し、二重の routing plane を作らない。
Step 11 — 検証
最低限:
テストが PASS しても、production caller graph を静的に再追跡する。
実際の caller chain を
rg/ AST / import tracing で提示し、canonical command
→ wrapper
→ classification
→ consumer
→ classifier
→ NEXT_ACTION projection
→ SKILL handoff
の各 edge が current head に存在することを証明する。
Step 12 — adversarial review loop
実装後、pr-review-judge / 独立 reviewer に次を重点確認させる:
_bounded_contract_update_handoff()等で route が脱落していないかissue_editor_requiredが contract-update retry を本当に止めるかREQUEST_CHANGES が出たら同一 PR で修正を継続する。
既存の Stop Condition「Allowed Paths 外変更」は今回更新した #2048 contract を正本とする。
レビュー APPROVE と全 required CI PASS までは Draft を維持する。
merge は通常の impl-review-loop policy に従う。
禁止
CONTRACT_PATCH_PLAN_V1にallowed_path_deltasを安易に追加しないoperations非listを[]に coercionしない最終報告では、
を簡潔に提示してください。
この方針なら、#2048 を縮小するのではなく、#1877 で一度踏んだ「unit test は通るが canonical path から到達不能」という失敗を、今回は transaction boundary で正面から塞いで実装を継続できます。GitHub への書き込み自体は今回行っていません。
fix: #2048 scope reframe route を consume_trusted_anchor_contract_patc…
fix: #2048 scope reframe を単一 canonical disposition classifier に統合し PR #…
fix: #2048 PR #2057 iteration4 blocker3 -- patch-plan producer unavai…
fix: #2048 PR #2057 レビュー指摘のコード内コメントを実際の解決状態に合わせて更新する