Skip to content

実装: 回帰: approved scope reframe に patch operations が無い場合、contract_update を再試行せず issue_editor_required へ route する #2048

Closed

Description

@squne121

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

Parent 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_required disposition では contract-update mutation を一切実行せず、wrapper(run_refinement_preflight.py の post-update handoff projection)まで route を実際に伝播させ、stdout の NEXT_ACTION と result artifact next_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_V1 schema への allowed_path_deltas フィールド追加(OWNER decision により不採用)
  • generic な patch plan consumer 全体の再設計(#1877 の既存実装を維持する。境界拡張のみ許可)
  • issue-editor の candidate body 生成ロジック自体の変更(既存 edit-issue skill の責務)
  • #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_required disposition が検出されたとき、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: 既存 #1835 fixture・#1877 regression 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/ -q

Allowed 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

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 9, 2026
  2. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    判定

    verdict: REQUEST_CHANGES
    implementation_readiness: blocked
    defect_validity: confirmed
    contract_completeness: insufficient
    primary_risk: canonical production route を変更せず、別 router のテストだけが PASS する
    issue_comments: 0
    

    総評

    #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 ではない

    レビュー時点の正規経路は概ね次です。

    scope_signal_delta.py
      ↓
    plan_refinement_loop.py
      ↓ scope_delta_authority.route.action
    decide_next_loop_action.py
      ↓ proceed_with_contract_update
    command_registry / privileged executor
      ↓
    run_refinement_preflight.py --consume-contract-patch-plan
      ↓
    consume_trusted_anchor_contract_patch_plan()
      ↓
    edit_issue_txn.py
      ↓
    final readback + fresh preflight/review/readiness
    

    一方、#2048 が中心に据えている経路は次です。

    route_after_rewrite.py
      ↓
    decide_rewrite_route.py
    

    decide_rewrite_route.py の参照をコード検索した範囲では、本体と単体テストしか確認できません。canonical Skill はこの router ではなく decide_next_loop_action.py を使用しています。

    したがって、AC1 の

    decide_rewrite_route.py が issue_editor_required を返す

    を満たしても、production の contract_update 再試行を止めた証明にはなりません。

    必須修正

    issue_editor_required の producer と consumer を、少なくとも次へ移してください。

    • producer: scope_signal_delta.py または plan_refinement_loop.py

    • canonical router: decide_next_loop_action.py

    • controlled phase consumer: run_refinement_preflight.py

    • orchestration contract: SKILL.md

    • 必要な場合のみ command_registry.py

    decide_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 は少なくとも次の状態を区別できません。

    A. patch operation を生成できなかった
    B. directive が既に満たされており no-change
    C. 対応外または曖昧な directive だった
    D. scope authorization しかなく、完全な body rewrite が必要
    E. producer の extraction / wiring defect
    

    #2048 の AC1 は、これらをすべて issue_editor_required に吸収する危険があります。特に C と E を issue-editor に流すと、planner failure を自動 rewrite に昇格させる fail-open になります。

    必須修正

    空配列を oracle にせず、明示的な排他的 disposition を producer が出してください。

    materialization:
      disposition: patch
      # または:
      # proven_no_change
      # full_rewrite_required
      # invalid
      reason_code: explicit_scope_reframe_requires_full_contract_rewrite
      operations: []
    

    最低限の不変条件は次です。

    patch:
      operations minItems: 1
      route: contract_update_required
    

    proven_no_change:
    operations maxItems: 0
    changed: false を section-aware candidate 比較で証明
    route: no_change

    full_rewrite_required:
    operations maxItems: 0
    trusted authorization と rewrite necessity を独立に証明
    route: issue_editor_required

    invalid:
    operations maxItems: 0
    route: human_escalation
    issue-editor / mutation 禁止

    JSON Schema では oneOf によって「必ず一つだけの分岐が成立する」契約を表現できます。 (JSON Schema)


    P0-3 — issue_editor_required が end-to-end の型付き契約になっていない

    現行の SCOPE_DELTA_AUTHORITY_V1.route.action は次の三値です。

    contract_update_required
    human_escalation
    not_triggered

    issue_editor_required は存在しません。next_step も rerun_refinement_after_contract_update または null に限定されています。

    また、refinement_preflight_result_v1 の contract_update.status は次の四値です。

    applied
    no_change
    rebased
    failed

    ここにも「正常な非失敗として issue-editor へ引き渡した」という状態がありません。next_action 自体は自由文字列ですが、自由文字列だけでは producer・router・consumer 間の enum parity を検証できません。

    #2048 のままでは、次のような分裂が起こり得ます。

    decide_rewrite_route:
    issue_editor_required

    scope_delta_authority:
    contract_update_required

    run_refinement_preflight:
    failed

    decide_next_loop_action:
    proceed_with_contract_update

    必須修正

    次を同じ変更単位で更新してください。

    1. authority/materialization schema

    2. planner producer

    3. decide_next_loop_action.py

    4. preflight result の typed handoff

    5. SKILL の action table

    6. issue-editor consumer

    7. 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

    • updatedAt

    • materialization disposition

    • planner/schema version

    また、同 wrapper は Issue body を取得しますが、title、anchor comment、patch operations を入力として持ちません。したがって、#2048 が求める「同じ anchor / body SHA / empty operations fingerprint」をこのファイル単独で判定できません。

    推奨 fingerprint は、例えば次の canonical object から生成します。

    {
    "schema_version": "scope-materialization/v1",
    "repo": "squne121/loop-protocol",
    "issue_number": 2040,
    "anchor_comment_id": 5229730571,
    "anchor_body_sha256": "sha256:...",
    "base_title_sha256": "sha256:...",
    "base_body_sha256": "sha256:...",
    "base_updated_at": "...",
    "disposition": "full_rewrite_required",
    "reason_code": "approved_scope_requires_full_contract_rewrite",
    "producer_version": "git-blob-sha:..."
    }

    永続的または実装言語横断の 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 publisher は一つだけ

    • issue 単位で writer を直列化
    • 全 comment page を取得
    • hidden marker に materialization fingerprint を格納
    • create 後に comment ID/body marker を readback
    • 同一 canonical writer の replay に限って duplicate 0 を保証

    P0-5 — AC4 の readback と implementation_allowed を誤った component に所有させている

    #2048 は route_after_rewrite.py に対し、

    body/title readback と fresh review/preflight 完了まで implementation_allowed=false

    を要求しています。

    しかし現行 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 は既に次を担当しています。

    candidate readiness
    mutation 前 Issue/anchor readback
    anchor trust 再検証
    一回だけの body drift rebase
    controlled transaction
    final Issue readback
    section postcondition
    fresh preflight
    fresh review
    fresh readiness

    これは run_refinement_preflight.py と run_trusted_anchor_iteration_zero() 側の責務です。

    したがって implementation_allowed は別 router で再計算せず、controlled consumer の最終結果からのみ導出すべきです。

    implementation_allowed = true
    iff
    final title readback verified
    AND final body readback verified
    AND fresh preflight pass/warn-allowed
    AND fresh review approve
    AND fresh readiness go
    AND all results bind final title/body SHA and tested main SHA

    fresh check の単なる文字列 pass では不十分です。少なくとも final title/body SHA、Issue updatedAt、tested main SHA を同じ handoff に束縛してください。


    P0-6 — Allowed Paths が実装に必要な正本を含まず、Stop Conditions と矛盾する

    現行 Allowed Paths には、少なくとも以下が不足しています。

    .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    .claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py
    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    .claude/skills/issue-refinement-loop/schemas/contract_patch_plan_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/scope_delta_authority_v1.schema.json
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py

    逆に、decide_rewrite_route.py に新しい state field を追加するなら、strict additionalProperties: 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 にすぎません。

    rg -n "issue_editor_required" ...
    rg -n "approved_scope_requires_full_contract_rewrite" ...
    rg -n "empty_operations_fingerprint" ...
    grep -c "duplicate_comment" ...
    test -f test_scope_only_reframe_route.py

    これらが 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 を維持」とすると、何を保護しているのか不明です。

    次のように具体化してください。

    - #1877:
      non-empty patch / no-change / one-rebase / final readback invariants
    
    • #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」に限定するなら、次が妥当です。

    ## Runtime Verification Applicability

    decision: not_applicable
    reason: >-
      本Issueは deterministic な planner/router/consumer 契約と、
      fake gh / fixture を用いた process-boundary E2E で検証できる。
      実GitHub Issue mutation や live Codex custom-agent dispatch を
      completion evidence として要求しない。
    </code></pre><pre><code>
    actual Codex `issue-editor` spawn まで Outcome に含める場合は `decision: immediate` に変更し、外部 mutation を伴わない bounded runtime smoke を追加する必要があります。
    
    ---
    
    # 推奨する最小アーキテクチャ
    
    新しい state store、publisher、receipt family は不要です。既存の authority sidecar と preflight result を型付きで拡張します。
    
    ```text
    scope_signal_delta.py
      └─ materialization.disposition を決定
            ├─ patch
            ├─ proven_no_change
            ├─ full_rewrite_required
            └─ invalid
                  ↓
    plan_refinement_loop.py
                  ↓
    decide_next_loop_action.py
            ├─ patch → proceed_with_contract_update
            ├─ proven_no_change → proceed_to_fresh_review
            ├─ full_rewrite_required → proceed_with_issue_editor
            └─ invalid → human_escalation
                  ↓
    run_refinement_preflight.py
            ├─ contract update consumer
            └─ issue-editor handoff producer
                  ↓
    issue-editor
      candidate title/body のみ生成
                  ↓
    edit_issue_txn.py
      controlled mutation + exact readback
                  ↓
    fresh preflight/review/readiness
    </code></pre><p>推奨 payload は次の形です。</p><pre><code class="language-yaml">materialization:
      schema_version: SCOPE_MATERIALIZATION_V1
      disposition: full_rewrite_required
      reason_code: approved_scope_requires_full_contract_rewrite
    
      binding:
        repo: squne121/loop-protocol
        issue_number: 2040
        anchor_comment_id: 5229730571
        anchor_body_sha256: sha256:...
        anchor_author_association: OWNER
        base_title_sha256: sha256:...
        base_body_sha256: sha256:...
        base_updated_at: "..."
    
      operations: []
    
      materialization_fingerprint: sha256:...
    
    route:
      action: issue_editor_required
      implementation_allowed: false
      next_step: run_issue_editor_then_controlled_edit
    </code></pre><p>ここで重要なのは、<code inline="">full_rewrite_required</code> が <strong>空配列から推測された値ではなく、producer が根拠付きで明示した値</strong>であることです。</p><hr><h1>推奨する修正版 Issue 契約</h1><h2>Outcome</h2><pre><code class="language-text">trusted anchor の scope authorization と Issue contract の materialization を分離する。
    
    materialization.disposition が full_rewrite_required と明示され、
    operations が空である場合のみ、canonical next-action router は
    contract_update を実行せず issue_editor_required を返す。
    
    空 operations だけから full rewrite を推測しない。
    unsupported、ambiguous、producer failure は fail-closed とする。
    
    issue-editor は candidate title/body の生成のみを担当し、
    mutation は既存 controlled edit transaction が実行する。
    final title/body readback と、final snapshot に束縛された
    fresh preflight/review/readiness が完了するまで
    implementation_allowed は false のままとする。
    </code></pre><h2>Acceptance Criteria</h2><pre><code class="language-text">AC1:
      materialization.disposition は
      patch | proven_no_change | full_rewrite_required | invalid
      の closed enum である。
    
    AC2:
      patch は operations が1件以上の場合だけ有効で、
      canonical router は contract_update_required を返す。
    
    AC3:
      proven_no_change は section-aware candidate comparison で
      current title/body と一致した場合だけ有効で、writes: 0 になる。
    
    AC4:
      full_rewrite_required は trusted anchor、base issue snapshot、
      explicit reason_code がすべて検証済みの場合だけ有効で、
      operations は空、contract_update invocation は0件、
      canonical router は issue_editor_required を返す。
    
    AC5:
      operations が空でも disposition 欠落、unsupported directive、
      extraction failure、untrusted/edited anchor の場合は
      issue-editor へ進まず fail-closed になる。
    
    AC6:
      materialization fingerprint は repo、issue、anchor ID/hash、
      base title/body hash、updatedAt、disposition、reason、
      producer/schema versionを束縛する。
      同一入力の別プロセス replay で同一 fingerprint/actionを返す。
    
    AC7:
      issue-editor handoff は strict schema valid であり、
     別Issue、別anchor、stale base snapshot の流用を拒否する。
    
    AC8:
      issue-editor は直接 GitHub mutation を行わず、
     既存 edit_issue_txn.py を使用する。
      final title/body の完全一致 readbackを必須とする。
    
    AC9:
      fresh preflight/review/readiness は final title/body SHA と
      tested main SHA に束縛され、不一致・旧artifactを拒否する。
    
    AC10:
      canonical Skill → planner → decide_next_loop_action →
      preflight consumer → issue-editor handoff → fake controlled transaction →
      final readback → fresh checks を通る process-boundary E2E が PASS する。
    
    AC11:
      #1877 の non-empty patch/no-change/rebase、
      #1952 の creator/editor role separation、
      関連する #1835 fixture の明示した invariant に回帰がない。
    
    AC12:
      この transition では scope reframe comment を投稿しない。
      コメントを残す場合は canonical single publisher、
      full pagination、fingerprint marker、serialized writer、
      create後readbackを検証する。
    </code></pre><h2>推奨 Allowed Paths</h2><pre><code class="language-text">.claude/skills/issue-refinement-loop/SKILL.md
    .claude/skills/issue-refinement-loop/references/loop-state.md
    
    .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
    .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
    .claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py
    .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    
    .claude/skills/issue-refinement-loop/schemas/contract_patch_plan_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/scope_delta_authority_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json
    
    .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority.py
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py
    .claude/skills/issue-refinement-loop/tests/test_scope_only_reframe_route.py
    .claude/skills/issue-refinement-loop/tests/test_issue_2040_scope_reframe_handoff.py
    </code></pre><p>actual issue-editor dispatch や executor policy を変更する場合だけ、追加します。</p><pre><code class="language-text">.claude/skills/edit-issue/SKILL.md
    .codex/agents/issue-editor.toml
    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    scripts/agent-guards/tests/
    </code></pre><p><code inline="">decide_rewrite_route.py</code> と <code inline="">route_after_rewrite.py</code> は、canonical route として正式に昇格させない限り除外する方が安全です。</p><h2>推奨 Verification Commands</h2><pre><code class="language-bash">uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority.py \
      .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py \
      .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py \
      .claude/skills/issue-refinement-loop/tests/test_scope_only_reframe_route.py \
      .claude/skills/issue-refinement-loop/tests/test_issue_2040_scope_reframe_handoff.py \
      -q
    </code></pre><pre><code class="language-bash">uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests \
      -q
    </code></pre><pre><code class="language-bash"># command registry / privileged executor を変更した場合のみ
    uv run --locked pytest scripts/agent-guards/tests -q
    </code></pre><pre><code class="language-bash">git diff --check
    </code></pre><h1>最終判断</h1><p>#2048 は問題設定としては妥当ですが、現状では実装開始不可です。最優先の修正は次の四点です。</p><ol><li><p><code inline="">operations[]</code> の空を full rewrite の意味として使わず、明示的 disposition を追加する。</p></li><li><p><code inline="">decide_rewrite_route.py</code> ではなく canonical <code inline="">decide_next_loop_action.py</code> と <code inline="">run_refinement_preflight.py</code> を変更対象にする。</p></li><li><p><code inline="">issue_editor_required</code> を schema・producer・router・consumer・handoff・readbackまで一続きの型付き契約にする。</p></li><li><p>grep/file-existence VC を、#2040 の実スナップショットを通す process-boundary E2E に置き換える。</p></li></ol><p>この修正を行わない場合、文字列検索と単体テストは PASS しても、production は引き続き <code inline="">contract_update → failed / writes: 0</code> を返す可能性が高く、#1877 / PR #1884 で発生した canonical-path defect を再導入します。</p></body></html><!--EndFragment-->
    </body>
    </html># 判定
    
    ```yaml
    verdict: REQUEST_CHANGES
    implementation_readiness: blocked
    defect_validity: confirmed
    contract_completeness: insufficient
    primary_risk: canonical production route を変更せず、別 router のテストだけが PASS する
    issue_comments: 0
    

    総評

    #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 ではない

    レビュー時点の正規経路は概ね次です。

    scope_signal_delta.py
      ↓
    plan_refinement_loop.py
      ↓ scope_delta_authority.route.action
    decide_next_loop_action.py
      ↓ proceed_with_contract_update
    command_registry / privileged executor
      ↓
    run_refinement_preflight.py --consume-contract-patch-plan
      ↓
    consume_trusted_anchor_contract_patch_plan()
      ↓
    edit_issue_txn.py
      ↓
    final readback + fresh preflight/review/readiness
    

    一方、#2048 が中心に据えている経路は次です。

    route_after_rewrite.py
      ↓
    decide_rewrite_route.py
    

    decide_rewrite_route.py の参照をコード検索した範囲では、本体と単体テストしか確認できません。canonical Skill はこの router ではなく decide_next_loop_action.py を使用しています。

    したがって、AC1 の

    decide_rewrite_route.py が issue_editor_required を返す

    を満たしても、production の contract_update 再試行を止めた証明にはなりません。

    必須修正

    issue_editor_required の producer と consumer を、少なくとも次へ移してください。

    • producer: scope_signal_delta.py または plan_refinement_loop.py
    • canonical router: decide_next_loop_action.py
    • controlled phase consumer: run_refinement_preflight.py
    • orchestration contract: SKILL.md
    • 必要な場合のみ command_registry.py

    decide_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 は少なくとも次の状態を区別できません。

    A. patch operation を生成できなかった
    B. directive が既に満たされており no-change
    C. 対応外または曖昧な directive だった
    D. scope authorization しかなく、完全な body rewrite が必要
    E. producer の extraction / wiring defect
    

    #2048 の AC1 は、これらをすべて issue_editor_required に吸収する危険があります。特に C と E を issue-editor に流すと、planner failure を自動 rewrite に昇格させる fail-open になります。

    必須修正

    空配列を oracle にせず、明示的な排他的 disposition を producer が出してください。

    materialization:
      disposition: patch
      # または:
      # proven_no_change
      # full_rewrite_required
      # invalid
      reason_code: explicit_scope_reframe_requires_full_contract_rewrite
      operations: []
    

    最低限の不変条件は次です。

    patch:
      operations minItems: 1
      route: contract_update_required
    
    proven_no_change:
      operations maxItems: 0
      changed: false を section-aware candidate 比較で証明
      route: no_change
    
    full_rewrite_required:
      operations maxItems: 0
      trusted authorization と rewrite necessity を独立に証明
      route: issue_editor_required
    
    invalid:
      operations maxItems: 0
      route: human_escalation
      issue-editor / mutation 禁止
    

    JSON Schema では oneOf によって「必ず一つだけの分岐が成立する」契約を表現できます。 (JSON Schema)


    P0-3 — issue_editor_required が end-to-end の型付き契約になっていない

    現行の SCOPE_DELTA_AUTHORITY_V1.route.action は次の三値です。

    contract_update_required
    human_escalation
    not_triggered
    

    issue_editor_required は存在しません。next_step も rerun_refinement_after_contract_update または null に限定されています。

    また、refinement_preflight_result_v1 の contract_update.status は次の四値です。

    applied
    no_change
    rebased
    failed
    

    ここにも「正常な非失敗として issue-editor へ引き渡した」という状態がありません。next_action 自体は自由文字列ですが、自由文字列だけでは producer・router・consumer 間の enum parity を検証できません。

    #2048 のままでは、次のような分裂が起こり得ます。

    decide_rewrite_route:
      issue_editor_required
    
    scope_delta_authority:
      contract_update_required
    
    run_refinement_preflight:
      failed
    
    decide_next_loop_action:
      proceed_with_contract_update
    

    必須修正

    次を同じ変更単位で更新してください。

    1. authority/materialization schema
    2. planner producer
    3. decide_next_loop_action.py
    4. preflight result の typed handoff
    5. SKILL の action table
    6. issue-editor consumer
    7. 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
    • updatedAt
    • materialization disposition
    • planner/schema version

    また、同 wrapper は Issue body を取得しますが、title、anchor comment、patch operations を入力として持ちません。したがって、#2048 が求める「同じ anchor / body SHA / empty operations fingerprint」をこのファイル単独で判定できません。

    推奨 fingerprint は、例えば次の canonical object から生成します。

    {
      "schema_version": "scope-materialization/v1",
      "repo": "squne121/loop-protocol",
      "issue_number": 2040,
      "anchor_comment_id": 5229730571,
      "anchor_body_sha256": "sha256:...",
      "base_title_sha256": "sha256:...",
      "base_body_sha256": "sha256:...",
      "base_updated_at": "...",
      "disposition": "full_rewrite_required",
      "reason_code": "approved_scope_requires_full_contract_rewrite",
      "producer_version": "git-blob-sha:..."
    }
    

    永続的または実装言語横断の fingerprint とするなら、単なる実装依存の JSON dump ではなく、RFC 8785 JCS またはリポジトリで同等に固定した canonicalization 契約を使うべきです。RFC 8785 は、JSON を hash/signature 用に再現可能な表現へ正規化する規則を定義しています。 ([RFC Editor]3)

    コメント重複防止

    AC3 の「同じ scope reframe comment を重複投稿しない」も ownership が未定義です。

    • どの script が投稿するのか
    • どの marker を検索するのか
    • 全ページを検索するのか
    • 並行 writer をどう直列化するのか
    • create 後の readback を行うのか

    がありません。

    GitHub の Issue comment 一覧はページングされ、既定件数だけを読んだ場合は古い marker を見落とします。全ページ取得には pagination link を処理する必要があります。 ([GitHub Docs]4)

    また、公式の comment create API の文書化された入力は本文が中心で、利用者が指定する idempotency key は確認できません。したがって、これは文書からの推論ですが、独立 writer 間での unconditional exactly-once を API 任せにはできません。GitHub も mutative request の直列化と間隔確保を推奨しています。 ([GitHub Docs]4)

    最小設計は、この transition ではコメントを投稿しないことです。typed preflight handoff だけで十分です。コメントが必要なら、次を AC に固定してください。

    - canonical publisher は一つだけ
    - issue 単位で writer を直列化
    - 全 comment page を取得
    - hidden marker に materialization fingerprint を格納
    - create 後に comment ID/body marker を readback
    - 同一 canonical writer の replay に限って duplicate 0 を保証
    

    P0-5 — AC4 の readback と implementation_allowed を誤った component に所有させている

    #2048 は route_after_rewrite.py に対し、

    body/title readback と fresh review/preflight 完了まで implementation_allowed=false

    を要求しています。

    しかし現行 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 は既に次を担当しています。

    candidate readiness
    mutation 前 Issue/anchor readback
    anchor trust 再検証
    一回だけの body drift rebase
    controlled transaction
    final Issue readback
    section postcondition
    fresh preflight
    fresh review
    fresh readiness
    

    これは run_refinement_preflight.py と run_trusted_anchor_iteration_zero() 側の責務です。

    したがって implementation_allowed は別 router で再計算せず、controlled consumer の最終結果からのみ導出すべきです。

    implementation_allowed = true
    iff
      final title readback verified
      AND final body readback verified
      AND fresh preflight pass/warn-allowed
      AND fresh review approve
      AND fresh readiness go
      AND all results bind final title/body SHA and tested main SHA
    

    fresh check の単なる文字列 pass では不十分です。少なくとも final title/body SHA、Issue updatedAt、tested main SHA を同じ handoff に束縛してください。


    P0-6 — Allowed Paths が実装に必要な正本を含まず、Stop Conditions と矛盾する

    現行 Allowed Paths には、少なくとも以下が不足しています。

    .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    .claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py
    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    .claude/skills/issue-refinement-loop/schemas/contract_patch_plan_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/scope_delta_authority_v1.schema.json
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py
    

    逆に、decide_rewrite_route.py に新しい state field を追加するなら、strict additionalProperties: 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 にすぎません。

    rg -n "issue_editor_required" ...
    rg -n "approved_scope_requires_full_contract_rewrite" ...
    rg -n "empty_operations_fingerprint" ...
    grep -c "duplicate_comment" ...
    test -f test_scope_only_reframe_route.py
    

    これらが 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 を維持」とすると、何を保護しているのか不明です。

    次のように具体化してください。

    - #1877:
      non-empty patch / no-change / one-rebase / final readback invariants
    
    - #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」に限定するなら、次が妥当です。

    ## Runtime Verification Applicability
    
    ```yaml
    decision: not_applicable
    reason: >-
      本Issueは deterministic な planner/router/consumer 契約と、
      fake gh / fixture を用いた process-boundary E2E で検証できる。
      実GitHub Issue mutation や live Codex custom-agent dispatch を
      completion evidence として要求しない。
    
    
    actual Codex `issue-editor` spawn まで Outcome に含める場合は `decision: immediate` に変更し、外部 mutation を伴わない bounded runtime smoke を追加する必要があります。
    
    ---
    
    # 推奨する最小アーキテクチャ
    
    新しい state store、publisher、receipt family は不要です。既存の authority sidecar と preflight result を型付きで拡張します。
    
    ```text
    scope_signal_delta.py
      └─ materialization.disposition を決定
            ├─ patch
            ├─ proven_no_change
            ├─ full_rewrite_required
            └─ invalid
                  ↓
    plan_refinement_loop.py
                  ↓
    decide_next_loop_action.py
            ├─ patch → proceed_with_contract_update
            ├─ proven_no_change → proceed_to_fresh_review
            ├─ full_rewrite_required → proceed_with_issue_editor
            └─ invalid → human_escalation
                  ↓
    run_refinement_preflight.py
            ├─ contract update consumer
            └─ issue-editor handoff producer
                  ↓
    issue-editor
      candidate title/body のみ生成
                  ↓
    edit_issue_txn.py
      controlled mutation + exact readback
                  ↓
    fresh preflight/review/readiness
    

    推奨 payload は次の形です。

    materialization:
      schema_version: SCOPE_MATERIALIZATION_V1
      disposition: full_rewrite_required
      reason_code: approved_scope_requires_full_contract_rewrite
    
      binding:
        repo: squne121/loop-protocol
        issue_number: 2040
        anchor_comment_id: 5229730571
        anchor_body_sha256: sha256:...
        anchor_author_association: OWNER
        base_title_sha256: sha256:...
        base_body_sha256: sha256:...
        base_updated_at: "..."
    
      operations: []
    
      materialization_fingerprint: sha256:...
    
    route:
      action: issue_editor_required
      implementation_allowed: false
      next_step: run_issue_editor_then_controlled_edit
    

    ここで重要なのは、full_rewrite_required が 空配列から推測された値ではなく、producer が根拠付きで明示した値であることです。


    推奨する修正版 Issue 契約

    Outcome

    trusted anchor の scope authorization と Issue contract の materialization を分離する。
    
    materialization.disposition が full_rewrite_required と明示され、
    operations が空である場合のみ、canonical next-action router は
    contract_update を実行せず issue_editor_required を返す。
    
    空 operations だけから full rewrite を推測しない。
    unsupported、ambiguous、producer failure は fail-closed とする。
    
    issue-editor は candidate title/body の生成のみを担当し、
    mutation は既存 controlled edit transaction が実行する。
    final title/body readback と、final snapshot に束縛された
    fresh preflight/review/readiness が完了するまで
    implementation_allowed は false のままとする。
    

    Acceptance Criteria

    AC1:
      materialization.disposition は
      patch | proven_no_change | full_rewrite_required | invalid
      の closed enum である。
    
    AC2:
      patch は operations が1件以上の場合だけ有効で、
      canonical router は contract_update_required を返す。
    
    AC3:
      proven_no_change は section-aware candidate comparison で
      current title/body と一致した場合だけ有効で、writes: 0 になる。
    
    AC4:
      full_rewrite_required は trusted anchor、base issue snapshot、
      explicit reason_code がすべて検証済みの場合だけ有効で、
      operations は空、contract_update invocation は0件、
      canonical router は issue_editor_required を返す。
    
    AC5:
      operations が空でも disposition 欠落、unsupported directive、
      extraction failure、untrusted/edited anchor の場合は
      issue-editor へ進まず fail-closed になる。
    
    AC6:
      materialization fingerprint は repo、issue、anchor ID/hash、
      base title/body hash、updatedAt、disposition、reason、
      producer/schema versionを束縛する。
      同一入力の別プロセス replay で同一 fingerprint/actionを返す。
    
    AC7:
      issue-editor handoff は strict schema valid であり、
     別Issue、別anchor、stale base snapshot の流用を拒否する。
    
    AC8:
      issue-editor は直接 GitHub mutation を行わず、
     既存 edit_issue_txn.py を使用する。
      final title/body の完全一致 readbackを必須とする。
    
    AC9:
      fresh preflight/review/readiness は final title/body SHA と
      tested main SHA に束縛され、不一致・旧artifactを拒否する。
    
    AC10:
      canonical Skill → planner → decide_next_loop_action →
      preflight consumer → issue-editor handoff → fake controlled transaction →
      final readback → fresh checks を通る process-boundary E2E が PASS する。
    
    AC11:
      #1877 の non-empty patch/no-change/rebase、
      #1952 の creator/editor role separation、
      関連する #1835 fixture の明示した invariant に回帰がない。
    
    AC12:
      この transition では scope reframe comment を投稿しない。
      コメントを残す場合は canonical single publisher、
      full pagination、fingerprint marker、serialized writer、
      create後readbackを検証する。
    

    推奨 Allowed Paths

    .claude/skills/issue-refinement-loop/SKILL.md
    .claude/skills/issue-refinement-loop/references/loop-state.md
    
    .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
    .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
    .claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py
    .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    
    .claude/skills/issue-refinement-loop/schemas/contract_patch_plan_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/scope_delta_authority_v1.schema.json
    .claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json
    
    .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority.py
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py
    .claude/skills/issue-refinement-loop/tests/test_scope_only_reframe_route.py
    .claude/skills/issue-refinement-loop/tests/test_issue_2040_scope_reframe_handoff.py
    

    actual issue-editor dispatch や executor policy を変更する場合だけ、追加します。

    .claude/skills/edit-issue/SKILL.md
    .codex/agents/issue-editor.toml
    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    scripts/agent-guards/tests/
    

    decide_rewrite_route.py と route_after_rewrite.py は、canonical route として正式に昇格させない限り除外する方が安全です。

    推奨 Verification Commands

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority.py \
      .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py \
      .claude/skills/issue-refinement-loop/tests/test_decide_next_loop_action_contract_update.py \
      .claude/skills/issue-refinement-loop/tests/test_scope_only_reframe_route.py \
      .claude/skills/issue-refinement-loop/tests/test_issue_2040_scope_reframe_handoff.py \
      -q
    
    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests \
      -q
    
    # command registry / privileged executor を変更した場合のみ
    uv run --locked pytest scripts/agent-guards/tests -q
    
    git diff --check
    

    最終判断

    #2048 は問題設定としては妥当ですが、現状では実装開始不可です。最優先の修正は次の四点です。

    1. operations[] の空を full rewrite の意味として使わず、明示的 disposition を追加する。
    2. decide_rewrite_route.py ではなく canonical decide_next_loop_action.py と run_refinement_preflight.py を変更対象にする。
    3. issue_editor_required を schema・producer・router・consumer・handoff・readbackまで一続きの型付き契約にする。
    4. grep/file-existence VC を、#2040 の実スナップショットを通す process-boundary E2E に置き換える。

    この修正を行わない場合、文字列検索と単体テストは PASS しても、production は引き続き contract_update → failed / writes: 0 を返す可能性が高く、#1877 / PR #1884 で発生した canonical-path defect を再導入します。

  3. self-assigned this
    on Aug 9, 2026
  4. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告

    結果: approved(1 iteration、review-issue VERDICT: approve、validator: valid)

    実施内容

    1. anchor comment(OWNER, https://github.com/squne121/loop-protocol/issues/2048#issuecomment-5230698037)を対象に preflight を実行
    2. run_refinement_preflight.py が deterministic repair 候補(VC の AC6 コマンド直前に # baseline-expect: fail annotation 挿入)を検出。auto-apply consumer が存在しないため一旦停止し、人間承認を得た上で issue-editor 経由で本文へ適用(BODY_HASH: sha256:f76950cc...。additive に ## Runtime Verification Applicability セクションも hygiene autofix で補完)
    3. codebase-investigator により repo fact claims(対象ファイル存在、decide_rewrite_route.py に contract_update は存在するが issue_editor_required は未実装、#1877 regression fixtures は存在し PASS、test_scope_only_reframe_route.py は未作成、VC baseline は全て fail)を全て confirmed
    4. issue-reviewer によるレビュー: C1-C11 全 pass、VERDICT: approve、validate_review_compact_output.py で valid 判定済み
    5. scope_delta_decision.status: fail_closed(scope reframe 対象ではない通常コメント)、scope_signal_guard.triggered: false

    最終状態

    • body sha256: sha256:3129a1c163f8a1d358ef60ef20cc1860599e017e93bb3fe88312ce8dacc3940c
    • Final Gate: decide_next_loop_action.py → STATUS: pass / NEXT_ACTION: proceed_to_step_4_5
    • follow-up materialization candidates: なし(parent_issue: none、単独 implementation issue)
    schema_version: loop_handoff_result/v1
    issue_number: 2048
    loop_outcome: approved
    reviewed_body_sha256: sha256:3129a1c163f8a1d358ef60ef20cc1860599e017e93bb3fe88312ce8dacc3940c
    issue_kind: implementation
    next_step: impl-review-loop
    implementation_allowed: true
    iterations: 1
  5. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-09)

  6. added a commit that references this issue on Aug 9, 2026
    3bd7ad7
  7. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    impl-review-loop 停止報告(Stop Condition 該当・人間判断待ち)

    2回のイテレーションでいずれも pr-review-judge から REQUEST_CHANGES を受け、両方とも同一の構造的原因でした:

    decide_scope_reframe_contract_route() を呼ぶ新規分岐が、実際の production 呼び出し元 consume_trusted_anchor_contract_patch_plan()(run_refinement_preflight.py:2310、Allowed Paths 外)から到達不能。

    control-plane(Opus)が独立に追跡した結果、以下が判明しました:

    1. consume_trusted_anchor_contract_patch_plan() の唯一の呼び出し元は run_refinement_preflight.py:3189 の1箇所のみで、この関数自体・呼び出し元ともに Allowed Paths 外
    2. run_trusted_anchor_iteration_zero() に渡される anchor 引数は生の GitHub コメント payload(dict(comment_payload))であり、scope reframe classification 結果(allowed_path_deltas を含む)を含まない
    3. 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 フィールドを持たない
    4. 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)。

    想定される解決策(人間判断が必要)

    • (a) run_refinement_preflight.py の consume_trusted_anchor_contract_patch_plan() / その呼び出し元を Allowed Paths に追加し、allowed_path_deltas を実際に転送する配線を許可する(Scope Delta)
    • (b) CONTRACT_PATCH_PLAN_V1 スキーマに allowed_path_deltas 相当のフィールドを追加する契約変更を承認する
    • (c) Issue のスコープを「到達可能性の実証を含まないライブラリ関数追加のみ」に縮小し、配線自体は別 Issue に切り出す

    現在の PR #2057(head 3bd7ad7697d0b9d2ed76642ca6c1b4e8347d2ec3)はこの状態で Draft のまま保持します。AC1-AC6 のユニットテストレベルの検証は全て PASS していますが、production 到達可能性は未証明です。

  8. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    結論

    推奨は (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 が実際に発生し、最終的に canonical contract_update phase を 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-level next_action を issue_editor_required に override するのが適切です。refinement_preflight_result_v1 の next_action は現在 enum ではなく単なる string なので、キー集合を変えずにこの routing を表現できます。 このケースでは contract update 自体を実行していないため、無理に contract_update.status=no_change と偽装するより、optional contract_update handoff を出さない方が意味論も明確です。

    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 の実装を継続してください。

    対象:

    OWNER decision:

    最重要ゴール

    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 を再取得

    最初に必ず以下を再取得する。

    PR 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
    • production-path regression に必要なら
      .claude/skills/issue-refinement-loop/tests/test_trusted_anchor_iteration_zero.py

    既存 Allowed Paths は必要なものを維持する。

    以下は原則として追加しない:

    • contract_patch_plan_v1.schema.json
    • command_registry.py
    • 新しい command-policy / privileged-executor surface
    • 新しい persistent schema / artifact family / receipt / publisher

    既存 contract_update.run.with_human_context を再利用できることを current main で確認すること。

    In Scope / Outcome / AC を、ファイル名ベースではなく production behavior ベースへ修正する。

    最低限、次を契約化する:

    1. trusted structured scope reframe の validated classification と patch plan を canonical consumer boundary で join する。
    2. empty operations[] 単独では issue_editor_required にしない。
    3. issue_editor_required では contract-update mutation を実行しない。
    4. route が wrapper/orchestrator まで実際に伝播する。
    5. issue-editor 後は final readback と fresh gates が完了するまで implementation を許可しない。
    6. process-boundary E2E で canonical command profile から route を証明する。

    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 が dict
    • status == "approved_by_trusted_anchor"
    • allowed_path_deltas が non-empty list[str]
    • consumer の repo / issue / anchor URL と decision の binding が一致
    • trusted anchor の body/hash binding が live readback と一致
    • contract_patch_plan["operations"] が list 型
    • malformed operations を [] に coercion しない
    • anchor / trust / hash / type mismatch は fail-closed

    Step 4 — empty operations の曖昧性を解消

    operations == [] を full rewrite の十分条件にしない。

    最低でも次の disposition を transaction-local に区別する:

    • patch

      • operations が non-empty
      • 既存 contract-update path をそのまま使用
    • proven_no_change

      • operations が empty
      • approved allowed_path_deltas が current Issue body に既にすべて反映済み
      • write 0
      • 既存 no-change semantics を維持
    • full_rewrite_required

      • trusted structured scope reframe
      • non-empty approved allowed_path_deltas
      • operations が正しい empty list
      • current Issue の Allowed Paths に approved delta が少なくとも1件未反映
      • patch representation では materialize できない
      • route = issue_editor_required
      • write 0
    • invalid

      • 型不正、binding 不一致、trust/hash drift、曖昧状態
      • human escalation
      • mutation 禁止

    新しい 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 に入る前に分岐する。

    推奨:

    • contract-update mutation callbackを呼ばない
    • _bounded_contract_update_handoff() の通常 success/failure 判定へ流さない
    • wrapper の既存 top-level next_action を
      issue_editor_required
      に設定する
    • stdout に
      NEXT_ACTION: issue_editor_required
      が出ること
    • result artifact の next_action も同値であること
    • この branch では contract update 自体を実行していないため、contract_update.status=no_change を full-rewrite-required の意味に流用しない
    • refinement_preflight_result_v1.contract_update に新 field/status を追加しない
    • top-level result schema のキー集合を変更しない

    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 を再実行しない
    • scope-reframe comment を再投稿しない
    • existing canonical issue-editor / edit-issue controlled transaction route に handoff
    • candidate body 生成ロジック自体は既存 issue-editor の責務を維持
    • mutation 前 optimistic concurrency / trusted-anchor readback を維持
    • mutation 後 body/title readback
    • fresh refinement preflight
    • fresh review
    • fresh readiness
    • Allowed Paths / permission / runtime evidence の既存 gate
    • これらが成立するまでは implementation を許可しない

    新しい mutation command profile を作る前に、既存 issue-editor/edit-issue route を検索して再利用すること。

    Step 7 — PR #2057 の過剰・非 canonical 実装を整理

    PRに現在存在する以下を敵対的に再評価する:

    • plan_refinement_loop.py の scope_delta_decision.operations opt-in route
    • route_after_rewrite.py の独立 implementation_allowed
    • duplicate-comment fingerprint machinery
    • decide_rewrite_route.py に追加された大きな独立 routing plane

    canonical 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 を行わない
    • comment dedupe のためだけの persistent fingerprint state を追加しない
    • AC3 は「同 transition は scope-reframe comment を publish しないため replay でも duplicate comment 0」として決定論的に検証する

    他の既存 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:

    • trusted OWNER human-context anchor
    • valid ANCHOR_SCOPE_REFRAME_V1
    • non-empty allowed_path_deltas
    • current body に delta が未反映
    • valid CONTRACT_PATCH_PLAN_V1
    • operations: []

    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_required
    • result artifact next_action == "issue_editor_required"
    • Issue write count = 0
    • apply_transaction 未呼び出し
    • contract-update retry commandを再発行しない
    • scope-reframe comment create = 0
    • no human escalation
    • schema validation PASS

    negative regressions:

    1. non-empty operations
      → existing contract_update behavior unchanged

    2. empty operations + no approved structured scope reframe
      → issue_editor_required にしない

    3. empty operations + approved reframe + all allowed_path_deltas already satisfied
      → proven no-change / existing safe route

    4. malformed operations type
      → fail-closed
      → empty list に coercion しない

    5. malformed/empty allowed_path_deltas
      → fail-closed

    6. anchor URL / issue / repo / body hash / trust drift
      → fail-closed、write 0

    7. 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

    • fresh preflight
    • fresh review
    • fresh readiness
    • Allowed Paths
    • permission profile
    • runtime evidence

    を確認する。

    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 に次を重点確認させる:

    • helperだけがPASSして production path が未接続ではないか
    • _bounded_contract_update_handoff() 等で route が脱落していないか
    • empty operations を無条件に full rewrite と解釈していないか
    • malformed input を empty に coercionして fail-openしていないか
    • issue_editor_required が contract-update retry を本当に止めるか
    • issue-editor後のfresh gateなしで implementation が許可されないか
    • planner / wrapper / route_after_rewrite に二重SSOTがないか
    • new comment publisher / schema / command surface を不必要に増やしていないか

    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しない
    • unit testのみで production reachability を主張しない
    • preflight read-only phase を mutation可能に変更しない
    • agent report / unlabeled anchor を human-context mutation lane に昇格しない
    • stale review/preflight を implementation authorization に再利用しない
    • generic consumer 全体の再設計へ拡大しない
    • unrelated Issue の修正を混載しない
    • secret の表示・変更、permission/security boundary の緩和、破壊的操作を行わない

    最終報告では、

    1. 更新した 実装: 回帰: approved scope reframe に patch operations が無い場合、contract_update を再試行せず issue_editor_required へ route する #2048 contract
    2. PR current head
    3. production caller chain
    4. disposition truth table
    5. write/comment count
    6. E2E evidence
    7. regression結果
    8. reviewer verdict
    9. 残存リスク
      を簡潔に提示してください。

    この方針なら、#2048 を縮小するのではなく、#1877 で一度踏んだ「unit test は通るが canonical path から到達不能」という失敗を、今回は transaction boundary で正面から塞いで実装を継続できます。GitHub への書き込み自体は今回行っていません。

  9. added 4 commits that reference this issue on Aug 9, 2026
    0710701
    ee572c2
    e02e667
    def94b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions