Skip to content

feat: owner_reaction_decision.py の selected 出力を not_planned heavy mutation gate へ限定接続する - #2697

Merged
squne121 merged 6 commits into
mainfrom
worktree-issue-2689-owner-reaction-heavy-mutation-gate
Sep 21, 2026
Merged

squne121 merged 6 commits into
mainfrom
worktree-issue-2689-owner-reaction-heavy-mutation-gate

Conversation

@squne121

@squne121 squne121 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

owner_reaction_decision.py(Issue #1975)は selected 判定結果を返すが、run_refinement_preflight.py の heavy mutation gate(_classify_heavy_mutation_gate() / _is_approved_close_not_planned_decision()、Issue #1891 / PR #2478)へは未接続で、既存 gate が唯一意味を持つ not_planned(close_not_planned)ケースを owner reaction 経由で承認する経路が存在しなかった(#1975 の明示的 Out of Scope)。

本 PR は、owner_reaction_decision.py の selected 出力を、既存 gate が唯一意味を持つ not_planned ケースに限定して production 接続する。

  • _is_approved_owner_reaction_not_planned_decision()(run_refinement_preflight.py): 既存の _is_approved_close_not_planned_decision() とは完全に独立した predicate。status == "selected" かつ selected_option_metadata.operation == "close_not_planned" かつ selected_option_metadata.target == f"#{issue_number}"(対象 Issue と完全一致)の場合のみ true を返す。selected を approved_by_trusted_anchor へ変換しない。同一 operation でも target が異なる option は承認済みとして扱わない。
  • _build_owner_reaction_decide_argv() / _run_owner_reaction_decision_fresh(): command_registry.py の owner_reaction.decide エントリと同一の --repo / --issue-number / --owner-user-id / --preview-binding-file 引数形状で owner_reaction_decision.py を fresh subprocess 実行する(キャッシュ・再利用なし)。_run_repair_subprocess() の既存 sibling-subprocess 呼び出し規約(sys.executable 直接起動)に倣う。
  • _classify_heavy_mutation_gate_with_fresh_owner_reaction(): mutation_category == "not_planned" かつ known_context["owner_reaction_context"]({"owner_user_id": <int>, "preview_binding_file": <path>})が渡された場合のみ、gate 評価の直前に fresh subprocess を実行し、その結果だけを _classify_heavy_mutation_gate() へ渡す。それ以外(未指定、または他の heavy mutation category)は 実装: owner_reaction_decision.py の出力を既存 heavy mutation gate へ統合する(#1975 の Out of Scope) #2689 以前と挙動が完全に同一。
  • _classify_heavy_mutation_gate() は owner_reaction_decision / target_issue_number を追加のキーワード専用引数(デフォルト None)として受理し、既存の exact_close_not_planned 分岐とは独立した OR 分岐として owner_reaction_not_planned_approved を追加。両分岐とも not_planned のみに限定。
  • run_preflight() の呼び出し箇所を新ラッパーへ差し替え。close / replacement_issue_creation / dependency_removal / parent_child_change は引き続き fail-closed のまま。
  • PR feat: owner_reaction_decision.py の selected 出力を not_planned heavy mutation gate へ限定接続する #2697 review fix_delta(P0-1、reviewer コメント #5755475318): 上記の gate 自体は接続されたが、command_registry.py がレンダリングする production argv には run_refinement_preflight.py の CLI へ --mutation-category / --owner-user-id / --preview-binding-file を渡す経路が一つも存在せず、_classify_heavy_mutation_gate_with_fresh_owner_reaction() が実 CLI 経由では到達不能だった。これを修正するため、command_registry.py の preflight.run.with_human_context / contract_update.run.with_human_context の2 command_id のエントリのみに、オプション atomic triple --mutation-category / --owner-user-id / --preview-binding-file(3つ揃って指定するか、3つとも省略するかのいずれかのみ許可)を追加。skill_runtime_command_policy.py の exact-grammar parser(parse_exact_skill_runtime_anchor_command())と skill_runtime_exec.py の main() に、この2 command_id のみ許可する all-or-none 検証(一部のみ指定・他の command_id への指定は exit 2)を追加。run_refinement_preflight.py の main() にも同じ CLI flag と all-or-none 検証(違反時 blocked/exit 2)を追加し、known_context["mutation_category"] / known_context["owner_reaction_context"] を materialize する。owner_reaction.decide 自体の argv 形状・_build_owner_reaction_decide_argv()(sys.executable 直接起動、skill_runtime_exec.py を経由しない設計は変更なし)には影響しない。新たな command_id・新たな mutation category は一切追加しない。
  • owner_reaction_decision.py はモジュール docstring のみ更新(実装: owner_reaction_decision.py の出力を既存 heavy mutation gate へ統合する(#1975 の Out of Scope) #2689 の consumer 側配線を追記)。reaction 読み取りロジックは無変更。
  • .claude/skills/issue-refinement-loop/SKILL.md の Reference Map を更新。

新規テスト:

  • test_owner_reaction_not_planned_gate.py: AC1〜AC5 相当(predicate の独立性・identity binding・fail-closed 分岐・fresh subprocess 検証・trusted-anchor 非混同)
  • test_owner_reaction_not_planned_gate_production_shaped.py: AC6(run_refinement_preflight.py を sys.executable で直接起動する real subprocess + 既存 fake-gh fixture owner_reaction_dispatch_fixture.py を再利用した producer→consumer path の production-shaped 検証。この subprocess chain は設計上 skill_runtime_exec.py を経由しない)
  • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_mutation_gate_transport_triple_reaches_real_subprocess_and_heavy_mutation_gate(fix_delta 追加、Blocker 2 対応): 既存 fixture _install_real_contract_update_fixture() を再利用し、real skill_runtime_exec.py subprocess に新 triple を渡して command_registry.render_command() / skill_runtime_command_policy.parse_exact_skill_runtime_anchor_command() を経て実際に子プロセスの argv が正しく組み立てられ、real run_refinement_preflight.py の heavy mutation gate(HEAVY_MUTATION_FAIL_CLOSED)まで到達することを検証

Checks

  • rg -n "_is_approved_owner_reaction_not_planned_decision" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py — マッチあり(AC1)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate.py -v — 12 passed
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate_production_shaped.py -v — 1 passed(AC6)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_run_refinement_preflight_credentialless_transport.py -v — 16 passed(AC7、無変更で継続 PASS)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_close_not_planned.py -q — 47 passed(既存 heavy mutation gate 呼び出し元の回帰確認)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decide_dispatch.py .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decide_failure_boundary.py .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decide_flag_validation.py -q — 37 passed(owner_reaction_decision.py docstring-only 変更の無回帰確認)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q -n auto — 2214 passed, 3 skipped, 5 failed(すべて pre-existing。3件は TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch(本 PR 変更前の main でも同一失敗を再現確認済み — 環境固有の既知事象、owner_reaction とは無関係)。残り2件は -n auto 並列実行時のみ発生する .claude/artifacts/issue-refinement-loop/2053/... 共有パスへの xdist worker 間書き込み競合(-p no:xdist の逐次実行では該当テストは PASS することを確認済み。本 PR の変更内容とは無関係)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py .claude/skills/issue-refinement-loop/tests/test_skill_md_wiring.py -q — 24 passed(SKILL.md thin entrypoint line budget 500 行以内を維持、498 行)
  • uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q — 21 passed(fix_delta 追加テスト含む既存 real-subprocess スイート全体の無回帰確認。新 triple を追加した command_registry.py / skill_runtime_command_policy.py / skill_runtime_exec.py の既存 real-subprocess 回帰カバレッジ)
  • uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_mutation_gate_transport_triple_reaches_real_subprocess_and_heavy_mutation_gate -v — 1 passed(fix_delta Blocker 2 対応の新規テスト)
  • pnpm typecheck / pnpm lint / pnpm test / pnpm build — 未実行。本 PR の変更は .claude/skills/issue-refinement-loop/ 配下の Python スクリプト・テスト・Markdown のみで、TypeScript/フロントエンドのソースコードには一切触れていないため対象外と判断(docs/dev/workflow.md の docs-only/非 TS 変更時の運用に準拠)
  • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 24 passed(無関係領域だが規約に従い実行)

Schema Change Applicability

Schema Consumer Inventory

N/A(not_schema_change のため。本 PR は既存 schema 出力(owner_reaction_decision.py の OWNER_REACTION_DECISION_RESULT_V1)の新規 in-process consumer を run_refinement_preflight.py 内部に追加するのみで、schema 自体の定義変更・外部 consumer 追加は行っていない)

Safety Claim Matrix

run_refinement_preflight.py の heavy mutation gate(_classify_heavy_mutation_gate())は Issue #1891 で導入された fail-closed 安全境界であり、本 PR はその承認経路を拡張するため safety-sensitive PR として扱う。

Claim Implemented? Not controlled Evidence Follow-up
新 predicate は not_planned category にのみ適用され、close / replacement_issue_creation / dependency_removal / parent_child_change の fail-closed 挙動は変更していない yes none test_unresolved_stale_environment_error_and_unsupported_category_fail_closed PASS(4 category すべてで status: blocked, fail_closed: True を確認) -
同一 close_not_planned operation でも target が異なる option は承認されない(identity binding) yes none test_same_category_different_target_rejected PASS。production-shaped テストでも target_issue_number=ISSUE_NUMBER+1 で再確認 -
unresolved / stale / environment_error の owner reaction 結果は承認されない yes none test_unresolved_stale_environment_error_and_unsupported_category_fail_closed PASS -
heavy mutation gate は同一 invocation 内の fresh subprocess 結果のみを使い、キャッシュ済み結果を再利用しない yes none test_gate_uses_fresh_invocation_result_only PASS(2回の呼び出しで異なる fake 結果を返し、gate 判定が都度追随することを確認) -
新 predicate は selected を approved_by_trusted_anchor に変換せず、既存 _is_approved_close_not_planned_decision() を呼び出さない yes none test_new_predicate_does_not_convert_to_approved_by_trusted_anchor PASS(AST ベースで実行本体に該当識別子・リテラルが存在しないことを検証) -
owner_reaction_context 未指定時・非 not_planned category 時は fresh subprocess を一切発行しない(無用な GitHub 読み取りの回避) yes none test_no_subprocess_issued_when_owner_reaction_context_absent / test_no_subprocess_issued_for_non_not_planned_category PASS -
scripts/agent-guards/skill_runtime_exec.py / command_registry.py / skill_runtime_command_policy.py への変更は、preflight.run.with_human_context / contract_update.run.with_human_context の2 command_id のみに限定したオプション atomic triple 追加であり、owner_reaction.decide 自体の argv 形状・新規 dispatch surface は追加していない(285 insertions / 13 deletions、3ファイル) yes none git diff --stat origin/main...HEAD -- scripts/agent-guards/skill_runtime_exec.py scripts/agent-guards/skill_runtime_command_policy.py .claude/skills/issue-refinement-loop/scripts/command_registry.py で確認可能(285 insertions(+), 13 deletions(-)) -
新 triple を正規の2 command_id で正しく指定した場合、real skill_runtime_exec.py subprocess がこれを受理し、command_registry.render_command() を経て子プロセス(real run_refinement_preflight.py)の argv へ実際に組み立てられ、heavy mutation gate まで到達する yes none test_mutation_gate_transport_triple_reaches_real_subprocess_and_heavy_mutation_gate PASS(real subprocess dispatch。extra_args 省略時は HEAVY_MUTATION_FAIL_CLOSED が出現しないことを別途手元で確認済み — 陽性/陰性の両方を区別できることを検証) -
新 triple の「一部のみ指定」「許可外 command_id への指定」に対する fail-closed(exit 2)は run_refinement_preflight.py / skill_runtime_exec.py / skill_runtime_command_policy.py それぞれにコード実装済みだが、real subprocess 経由でこの否定的経路(拒否)を明示的に検証する新規テストは本 PR には含まれない no 一部のみ指定時の real-subprocess レベル拒否テスト 実装コードは skill_runtime_exec.py L2651-2691 / run_refinement_preflight.py L10658-10672 / skill_runtime_command_policy.py の exact-grammar parser 参照。テストなし follow-up 起票を検討(本 PR スコープ外、fix_delta Blocker 2 は肯定的経路の実 subprocess 検証のみを要求)

Runtime Verification Evidence(動作検証証跡、AC4/AC6)

Runtime Verification Applicability: immediate(Issue #2689 本文)。applicable_acs: AC4, AC6。実行環境は GitHub network 通信なしで完結する(fake-gh fixture + real skill_runtime_exec.py subprocess)。以下は本 PR head(.claude/worktrees/issue-2689-owner-reaction-heavy-mutation-gate checkout)で実行した実ログ。

AC4: heavy mutation gate 評価直前に owner_reaction_decision.py が fresh subprocess 実行され、同一 invocation 内の結果のみが使われる。

  • 判定(Result): PASS
  • 実行日時(Timestamp、UTC): 2026-09-21T03:30:56Z
  • 実行環境(Environment): Linux WSL2 6.18.33.2-microsoft-standard-WSL2 / Python 3.12.3 / uv 0.11.29 / pytest 9.0.3
  • 終了コード(Exit Code): 0
実行ログ(クリックで展開)
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate.py::test_gate_uses_fresh_invocation_result_only -v
collecting ... collected 1 item

.claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate.py::test_gate_uses_fresh_invocation_result_only PASSED [100%]

============================== 1 passed in 0.26s ===============================

AC6: owner_reaction.decide の実行結果が heavy mutation gate 判定へ到達する producer→consumer path が1本通る(real subprocess chain)。

fix_delta(PR #2697 review、Blocker 2)で判明した通り、この producer→consumer path は run_refinement_preflight.py を sys.executable で直接起動する real subprocess であり、その内部の _run_owner_reaction_decision_fresh()(owner_reaction_decision.py を起動する nested real subprocess)は設計上 意図的に scripts/agent-guards/skill_runtime_exec.py を経由しない(_build_owner_reaction_decide_argv() の docstring に明記の通り、_run_repair_subprocess() と同じ sibling-subprocess 規約に倣う)。

  • 判定(Result): PASS
  • 実行日時(Timestamp、UTC): 2026-09-21T07:07:14Z
  • 実行環境(Environment): Linux WSL2 6.18.33.2-microsoft-standard-WSL2 / Python 3.12.3 / uv 0.11.29 / pytest 9.0.3
  • 終了コード(Exit Code): 0
実行ログ(クリックで展開)
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate_production_shaped.py::test_selected_not_planned_reaches_gate_via_real_subprocess -v
collecting ... collected 1 item

.claude/skills/issue-refinement-loop/tests/test_owner_reaction_not_planned_gate_production_shaped.py::test_selected_not_planned_reaches_gate_via_real_subprocess PASSED [100%]

============================== 1 passed in 0.51s ===============================

AC6 補足(fix_delta 追加、Blocker 2 対応): preflight.run.with_human_context / contract_update.run.with_human_context の production transport(command_registry.py が rendering する real skill_runtime_exec.py subprocess 経由)が、新 triple --mutation-category / --owner-user-id / --preview-binding-file を実際に受理し、real run_refinement_preflight.py の heavy mutation gate まで到達させる。

上記 AC6 本体の producer→consumer path が経由しない skill_runtime_exec.py 自体を real subprocess として起動し、新 triple の command_text 再構築・render_command() を経た argv 組み立てが正しく動作することを検証する(reviewer 推奨 (a))。

  • 判定(Result): PASS
  • 実行日時(Timestamp、UTC): 2026-09-21T07:07:30Z
  • 実行環境(Environment): Linux WSL2 6.18.33.2-microsoft-standard-WSL2 / Python 3.12.3 / uv 0.11.29 / pytest 9.0.3
  • 終了コード(Exit Code): 0
実行ログ(クリックで展開)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_mutation_gate_transport_triple_reaches_real_subprocess_and_heavy_mutation_gate -v
collecting ... collected 1 item

scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_mutation_gate_transport_triple_reaches_real_subprocess_and_heavy_mutation_gate PASSED [100%]

============================== 1 passed in 8.51s ===============================

Notes

…ation gate へ限定接続する (#2689)

run_refinement_preflight.py の heavy mutation gate (_classify_heavy_mutation_gate,
#1891 AC6) は close_not_planned の trusted-anchor 承認しか受理できず、
owner_reaction_decision.py (#1975) の selected 判定結果を消費する経路が
未接続だった (#1975 Out of Scope)。

- _is_approved_owner_reaction_not_planned_decision(): 既存の
  _is_approved_close_not_planned_decision() とは独立した predicate。
  status==selected かつ operation==close_not_planned かつ target が対象
  Issue と完全一致する場合のみ true を返し、selected を
  approved_by_trusted_anchor へ変換しない。
- _run_owner_reaction_decision_fresh() / _build_owner_reaction_decide_argv():
  owner_reaction.decide と同一の argv 形状で owner_reaction_decision.py を
  fresh subprocess 実行する(キャッシュなし)。
- _classify_heavy_mutation_gate_with_fresh_owner_reaction(): mutation_category
  が not_planned かつ known_context["owner_reaction_context"] が渡された
  場合のみ、gate 評価直前に fresh subprocess を実行して結果を gate へ渡す。
  それ以外は #2689 以前と挙動が完全に同一。
- close / replacement_issue_creation / dependency_removal /
  parent_child_change は引き続き fail-closed のまま。
- scripts/agent-guards/skill_runtime_exec.py / command_registry.py /
  skill_runtime_command_policy.py への変更なし。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2697 closed).

@squne121

Copy link
Copy Markdown
Owner Author

PR Review (impl-review-loop Step 4)

Mergeability

  • mergeable=MERGEABLE, merge_state_status=CLEAN, head=38ff3859ca8c55e35b8402252904e73d10238b20

Evidence Check

  • gh pr diff --name-only: 変更ファイルはIssue #2689のAllowed Paths内5件のみ(.claude/skills/issue-refinement-loop/SKILL.md, scripts/owner_reaction_decision.py, scripts/run_refinement_preflight.py, tests/test_owner_reaction_not_planned_gate.py, tests/test_owner_reaction_not_planned_gate_production_shaped.py)
  • 独立clean checkoutでAC1〜AC7のVerification Commandsを再実行し全PASSを確認(rg 3マッチ、pytest計47+16+24件PASS)
  • forbidden files(skill_runtime_exec.py/command_registry.py/skill_runtime_command_policy.py)への変更なし
  • 独立predicate_is_approved_owner_reaction_not_planned_decision()は既存_is_approved_close_not_planned_decision()を呼ばず、approved_by_trusted_anchor変換もしないことをAST/目視で確認
  • 全required CI checksがcurrent headでpass

Blockers

(なし)

Warnings

(なし)

verdict: APPROVE
reviewed_head_sha: "38ff3859ca8c55e35b8402252904e73d10238b20"
blockers: []
warnings: []

@squne121

Copy link
Copy Markdown
Owner Author

結論

PR #2697 は REQUEST_CHANGES 相当です。

not_planned のみに限定すること、operation + target の完全一致、trusted-anchor authority と owner-reaction authority を分離すること、gate 直前の fresh readback という設計判断自体は妥当です。一方で、その新経路を canonical production entrypoint から発火させる transport が実装されていません。さらに「production-shaped」とされているテストがその欠落部分を迂回しているため、CI と impl-review-loop: APPROVE が green でも主要機能が production では到達不能な false-green になっています。

確認対象は PR head 38ff3859ca8c55e35b8402252904e73d10238b20、Issue #2689、親 #1950、#1975、#1891 / PR #2478、#2688 / PR #2694、PR/Issue コメント、run_refinement_preflight.py、command_registry.py、skill_runtime_exec.py 系、owner-reaction の既存テスト群です。現在の main は 001ced10bb34f610f68fb6459936123630d6839e で、required CI は head に対して成功しています。

重要度 | Finding | 判定 -- | -- | -- P0 | canonical production path から mutation_category / owner_reaction_context を供給する経路がない | Blocker P0 | production-shaped test が producer と consumer をテストコードで手動接続しており、上記 transport 欠落を検出できない | Blocker P1 | _run_owner_reaction_decision_fresh() が child の non-zero returncode を確認していない | 修正推奨 P2 | 新 predicate が OWNER_REACTION_DECISION_RESULT_V1 の schema identity を検証していない | 軽微

P0 — production wiring が依然として到達不能

PR が追加した実 production call-site は run_refinement_preflight.py のこの条件です。

if known_context and known_context.get("mutation_category"):
    _heavy_mutation_gate = (
        _classify_heavy_mutation_gate_with_fresh_owner_reaction(
            mutation_category=known_context.get("mutation_category"),
            scope_delta_decision=known_context.get("scope_delta_decision"),
            owner_reaction_context=known_context.get("owner_reaction_context"),
            repo=repo,
            issue_number=issue_number,
        )
    )

ところが PR head 全体を追うと、owner_reaction_context の出現はこの新規 wrapper/call-site 周辺だけで、値を生成する production producer がありません。さらに mutation_category も既存 gate とテストでは使われていますが、canonical CLI が生成していません。

run_refinement_preflight.py::main() が実際に組み立てる cli_known_context は現在も、

cli_known_context = {
    human_context_comment_urls: ...,
    agent_report_comment_urls: ...,
}

だけです。--mutation-category、--owner-user-id、--preview-binding-file に相当する CLI transport はありません。

同様に command_registry.py の preflight.run.with_human_context と contract_update.run.with_human_context にも、新経路が必要とする値はありません。したがって、

skill_runtime_exec → command_registry → run_refinement_preflight.py → run_preflight()

という canonical path では、known_context.get("mutation_category") の外側の if にすら入りません。

これは特に重要で、Issue #2689 の初期 adversarial review コメント #5754526086 がまさにこの false-green を警告していました。その後の refinement で「sibling subprocess なら Allowed Paths 内だけで production wiring が成立する」という契約に書き換えられていますが、subprocess を呼ぶコードを置いただけで、それを起動するための context transport は解決されていません。

P0 — AC6 の「production-shaped」テストが欠落区間をバイパスしている

test_owner_reaction_not_planned_gate_production_shaped.py は前半は良いです。real skill_runtime_exec.py → real owner_reaction.decide.fixture → real owner_reaction_decision.py を通し、fake gh は network boundary に限定しています。

問題は後半です。取得した producer_payload をテストコード自身が直接、

preflight._is_approved_owner_reaction_not_planned_decision(...)
preflight._classify_heavy_mutation_gate(
    mutation_category="not_planned",
    owner_reaction_decision=producer_payload,
    ...
)

へ渡しています。

つまりこのテストは 本PRで新設した production wrapper
_classify_heavy_mutation_gate_with_fresh_owner_reaction() すら通っていません。

まして、

  • preflight.run.with_human_context

  • contract_update.run.with_human_context

  • CLI main()

  • run_preflight()

  • known_context["owner_reaction_context"] の materialization

は一切検証していません。

一方、wrapper の fresh-call テストは owner_reaction_context を hand-crafted dict で注入しています。

結果として、

producer は本物、consumer は本物だが、producer→consumer transport はテストコードが代行している

状態です。今回もっとも壊れやすい境界だけが試験対象から抜けています。

CI 全成功や PR コメント #5755414995 の APPROVE / blockers: [] は、この点を反証しません。GitHub上にも formal review submission / inline review thread は現時点でなく、この APPROVE はトップレベルの自己レビューコメントです。

P1 — subprocess の non-zero exit を無視している

_run_owner_reaction_decision_fresh() の docstring は non-zero exit を transport failure として None にすると宣言しています。しかし実装は、

proc = runner(..., check=False)

stdout = getattr(proc, "stdout", None)
...
parsed = json.loads(stdout)
return parsed if isinstance(parsed, dict) else None

で、proc.returncode を一度も確認していません。

一方 owner_reaction_decision.py::main() は environment_error の場合、structured JSON を stdout に出したうえで exit 1 を返します。

現状はその JSON の status == "environment_error" を後段 predicate が拒否するので accidental allow にはなっていません。ただし「nonzero は transport failure」という関数契約とは明確に不一致です。

Python の subprocess.run(..., check=False) は非0終了を自動的には例外化せず、CompletedProcess.returncode を呼び出し側が確認する必要があります。(Python documentation)

ここは harness を増やす必要はなく、

if getattr(proc, "returncode", 1) != 0:
return None

と、returncode=1 + parseable JSON のテスト1件で十分です。

P2 — schema identity の確認がない

_is_approved_owner_reaction_not_planned_decision() は、

status → selected_option_metadata.operation → target

だけを確認し、decision["schema"] == "OWNER_REACTION_DECISION_RESULT_V1" は見ていません。

production transport が完全に閉じていれば実害は限定的なので、これは blocker にするほどではありません。ただ、関数自身が「V1-shaped dict を読む」と契約している以上、1行の schema equality check を追加する方が契約として明確です。新しい validation framework は不要です。

既存実装で維持すべき部分

owner reaction reader 自体は作り直す必要はありません。GitHub REST の issue-comment reactions は reaction ごとに user.id を返し、ページングされるAPIです。GitHub CLI の gh api --paginate は全ページを順次取得し、--slurp で各ページをまとめられるため、#1975/#2683 側の「stable user ID + 全ページ取得」という方針は公式仕様と整合しています。(GitHub Docs)

また今回追加された以下は維持してよいです。

not_planned 以外を開放しないこと、selected_option_metadata.operation == "close_not_planned" を要求すること、target == f"#{issue_number}" の exact binding、selected を approved_by_trusted_anchor に変換しないことです。ここは Issue #2689 の初期 adversarial review で指摘された category-collapse 問題を適切に解消しています。

最小修正方針

このプロジェクトが個人趣味開発で、workflow の実用性を優先する前提なら、generic authorization framework、ledger、TTL、追加publisherなどは不要です。

必要なのは canonical preflight invocation が mutation_category と owner-reaction の実行に必要な context を実際に渡せる最短の transport を1本作ることです。現在の Allowed Paths だけではそれが成立しないなら、Issue #2689 の Stop Condition に従って Allowed Paths の前提を修正する方が、到達不能コードを維持するより良いです。

そのうえで AC6 のテストを、producer payload をPythonから直接 gate に渡す方式ではなく、real canonical preflight entrypoint → context materialization → fresh owner_reaction subprocess → heavy mutation gate まで1本通す形に変更するべきです。fake gh fixture は今あるものを再利用すればよく、新しい大規模 harness は不要です。

この2点と non-zero exit check を直せば、PRの設計方向そのものはかなり良く、追加のセキュリティ機構を増やす必要はありません。現状の最大問題は安全性不足ではなく、「実装した経路が production から呼ばれない」という機能的な未接続です。

## 結論

PR #2697 は REQUEST_CHANGES 相当です。

not_planned のみに限定すること、operation + target の完全一致、trusted-anchor authority と owner-reaction authority を分離すること、gate 直前の fresh readback という設計判断自体は妥当です。一方で、その新経路を canonical production entrypoint から発火させる transport が実装されていません。さらに「production-shaped」とされているテストがその欠落部分を迂回しているため、CI と impl-review-loop: APPROVE が green でも主要機能が production では到達不能な false-green になっています。

確認対象は PR head 38ff3859ca8c55e35b8402252904e73d10238b20、Issue #2689、親 #1950、#1975、#1891 / PR #2478、#2688 / PR #2694、PR/Issue コメント、run_refinement_preflight.py、command_registry.py、skill_runtime_exec.py 系、owner-reaction の既存テスト群です。現在の main は 001ced10bb34f610f68fb6459936123630d6839e で、required CI は head に対して成功しています。

重要度 Finding 判定
P0 canonical production path から mutation_category / owner_reaction_context を供給する経路がない Blocker
P0 production-shaped test が producer と consumer をテストコードで手動接続しており、上記 transport 欠落を検出できない Blocker
P1 _run_owner_reaction_decision_fresh() が child の non-zero returncode を確認していない 修正推奨
P2 新 predicate が OWNER_REACTION_DECISION_RESULT_V1 の schema identity を検証していない 軽微

P0 — production wiring が依然として到達不能

PR が追加した実 production call-site は run_refinement_preflight.py のこの条件です。

if known_context and known_context.get("mutation_category"):
    _heavy_mutation_gate = (
        _classify_heavy_mutation_gate_with_fresh_owner_reaction(
            mutation_category=known_context.get("mutation_category"),
            scope_delta_decision=known_context.get("scope_delta_decision"),
            owner_reaction_context=known_context.get("owner_reaction_context"),
            repo=repo,
            issue_number=issue_number,
        )
    )

ところが PR head 全体を追うと、owner_reaction_context の出現はこの新規 wrapper/call-site 周辺だけで、値を生成する production producer がありません。さらに mutation_category も既存 gate とテストでは使われていますが、canonical CLI が生成していません。

run_refinement_preflight.py::main() が実際に組み立てる cli_known_context は現在も、

cli_known_context = {
    human_context_comment_urls: ...,
    agent_report_comment_urls: ...,
}

だけです。--mutation-category、--owner-user-id、--preview-binding-file に相当する CLI transport はありません。

同様に command_registry.py の preflight.run.with_human_context と contract_update.run.with_human_context にも、新経路が必要とする値はありません。したがって、

skill_runtime_exec → command_registry → run_refinement_preflight.py → run_preflight()

という canonical path では、known_context.get("mutation_category") の外側の if にすら入りません。

これは特に重要で、Issue #2689 の初期 adversarial review コメント #5754526086 がまさにこの false-green を警告していました。その後の refinement で「sibling subprocess なら Allowed Paths 内だけで production wiring が成立する」という契約に書き換えられていますが、subprocess を呼ぶコードを置いただけで、それを起動するための context transport は解決されていません。

P0 — AC6 の「production-shaped」テストが欠落区間をバイパスしている

test_owner_reaction_not_planned_gate_production_shaped.py は前半は良いです。real skill_runtime_exec.py → real owner_reaction.decide.fixture → real owner_reaction_decision.py を通し、fake gh は network boundary に限定しています。

問題は後半です。取得した producer_payload をテストコード自身が直接、

preflight._is_approved_owner_reaction_not_planned_decision(...)
preflight._classify_heavy_mutation_gate(
    mutation_category="not_planned",
    owner_reaction_decision=producer_payload,
    ...
)

へ渡しています。

つまりこのテストは 本PRで新設した production wrapper
_classify_heavy_mutation_gate_with_fresh_owner_reaction() すら通っていません。

まして、

  • preflight.run.with_human_context
  • contract_update.run.with_human_context
  • CLI main()
  • run_preflight()
  • known_context["owner_reaction_context"] の materialization

は一切検証していません。

一方、wrapper の fresh-call テストは owner_reaction_context を hand-crafted dict で注入しています。

結果として、

producer は本物、consumer は本物だが、producer→consumer transport はテストコードが代行している

状態です。今回もっとも壊れやすい境界だけが試験対象から抜けています。

CI 全成功や PR コメント #5755414995 の APPROVE / blockers: [] は、この点を反証しません。GitHub上にも formal review submission / inline review thread は現時点でなく、この APPROVE はトップレベルの自己レビューコメントです。

P1 — subprocess の non-zero exit を無視している

_run_owner_reaction_decision_fresh() の docstring は non-zero exit を transport failure として None にすると宣言しています。しかし実装は、

proc = runner(..., check=False)

stdout = getattr(proc, "stdout", None)
...
parsed = json.loads(stdout)
return parsed if isinstance(parsed, dict) else None

で、proc.returncode を一度も確認していません。

一方 owner_reaction_decision.py::main() は environment_error の場合、structured JSON を stdout に出したうえで exit 1 を返します。

現状はその JSON の status == "environment_error" を後段 predicate が拒否するので accidental allow にはなっていません。ただし「nonzero は transport failure」という関数契約とは明確に不一致です。

Python の subprocess.run(..., check=False) は非0終了を自動的には例外化せず、CompletedProcess.returncode を呼び出し側が確認する必要があります。([Python documentation]1)

ここは harness を増やす必要はなく、

if getattr(proc, "returncode", 1) != 0:
    return None

と、returncode=1 + parseable JSON のテスト1件で十分です。

P2 — schema identity の確認がない

_is_approved_owner_reaction_not_planned_decision() は、

status → selected_option_metadata.operation → target

だけを確認し、decision["schema"] == "OWNER_REACTION_DECISION_RESULT_V1" は見ていません。

production transport が完全に閉じていれば実害は限定的なので、これは blocker にするほどではありません。ただ、関数自身が「V1-shaped dict を読む」と契約している以上、1行の schema equality check を追加する方が契約として明確です。新しい validation framework は不要です。

既存実装で維持すべき部分

owner reaction reader 自体は作り直す必要はありません。GitHub REST の issue-comment reactions は reaction ごとに user.id を返し、ページングされるAPIです。GitHub CLI の gh api --paginate は全ページを順次取得し、--slurp で各ページをまとめられるため、#1975/#2683 側の「stable user ID + 全ページ取得」という方針は公式仕様と整合しています。([GitHub Docs]2)

また今回追加された以下は維持してよいです。

not_planned 以外を開放しないこと、selected_option_metadata.operation == "close_not_planned" を要求すること、target == f"#{issue_number}" の exact binding、selected を approved_by_trusted_anchor に変換しないことです。ここは Issue #2689 の初期 adversarial review で指摘された category-collapse 問題を適切に解消しています。

最小修正方針

このプロジェクトが個人趣味開発で、workflow の実用性を優先する前提なら、generic authorization framework、ledger、TTL、追加publisherなどは不要です。

必要なのは canonical preflight invocation が mutation_category と owner-reaction の実行に必要な context を実際に渡せる最短の transport を1本作ることです。現在の Allowed Paths だけではそれが成立しないなら、Issue #2689 の Stop Condition に従って Allowed Paths の前提を修正する方が、到達不能コードを維持するより良いです。

そのうえで AC6 のテストを、producer payload をPythonから直接 gate に渡す方式ではなく、real canonical preflight entrypoint → context materialization → fresh owner_reaction subprocess → heavy mutation gate まで1本通す形に変更するべきです。fake gh fixture は今あるものを再利用すればよく、新しい大規模 harness は不要です。

この2点と non-zero exit check を直せば、PRの設計方向そのものはかなり良く、追加のセキュリティ機構を増やす必要はありません。現状の最大問題は安全性不足ではなく、「実装した経路が production から呼ばれない」という機能的な未接続です。

@squne121

Copy link
Copy Markdown
Owner Author

確認した限り、推奨は そのまま現行 Allowed Paths 内で修正を続けるのではなく、#2697 の P0 を根拠に #2689 を最小限 reframe してから impl-review-loop を再開です。

対象コメントは OWNER による明示的な REQUEST_CHANGES で、現在の PR はまだ draft/open、head は 38ff3859ca8c55e35b8402252904e73d10238b20 です。P0 の指摘どおり、現状の canonical path には mutation_category / owner_reaction_context の production producer/transport がありません。一方 #2689 は command_registry.py / skill_runtime_exec.py / skill_runtime_command_policy.py を明示的に Out of Scope にしているため、コードだけ直すと Allowed Paths gate で再び矛盾します。

したがって、このユーザープロンプト自体を「Stop Condition で要求されていた owner/operator 判断」として扱わせ、P0 解消に必要な最小 transport ファイルだけ #2689 の Allowed Paths に追加するのが整合的です。P1 の non-zero exit check と P2 の schema identity check も小さいので同じ fix_delta で潰すのがよいです。

以下を、既に auto mode で動いている Claude Code にそのまま渡せます。

PR #2697 を対象に、以下の OWNER review comment を authoritative fix_delta として impl-review-loop を再開してください。

Target PR:
#2697

Target review / human context:
#2697 (comment)

Linked Issue:
#2689

現在確認済みの PR head:
38ff3859ca8c55e35b8402252904e73d10238b20

使用する skill:
.claude/skills/impl-review-loop/SKILL.md

目的は、対象 OWNER comment の blocker を解消し、実装 → 独立検証 → PR review のループを マージ直前の canonical approved / draft_pr_ready 状態まで、人間への逐次承認要求なしで自律継続することです。

PR の merge 自体は実行しないでください。

この入力の authority

対象 comment #5755475318 は単なる参考レビューではなく、今回の fix_delta として扱ってください。

これは「停止せよ」という human veto ではなく、明示的な REQUEST_CHANGES / 修正指示です。

また Issue #2689 の Stop Conditions にある

  • Allowed Paths 外の変更が必要な場合は別途判断する
  • skill_runtime_exec.py / command_registry.py / skill_runtime_command_policy.py が必要なら scope 前提を再判断する

については、このプロンプトをその operator decision として扱って構いません。

P0 を独立調査して本当に canonical transport の変更が必要だと確認できた場合、以下の 最小限の scope expansion を追加承認なしで materialize してよいものとします。

最大許可範囲:

これ以上の scope 拡大は行わないでください。

最初に SubAgent で独立調査する

実装を始める前に、main orchestrator から独立した SubAgent を起動してください。

最低でも以下の3観点を別々に調べてください。

  1. production transport investigator

    • current PR head と current main を読む
    • skill_runtime_exec.py
    • skill_runtime_command_policy.py
    • command_registry.py
    • run_refinement_preflight.py::main()
    • cli_known_context
    • run_preflight()
    • heavy mutation gate
    • owner_reaction_decision.py
      を実際に追跡する
    • canonical invocation から
      mutation_category
      owner_user_id
      preview_binding_file
      がどこで失われているかを特定する
    • current Allowed Paths 内だけで production reachability を成立させられるかを判定する
  2. contract/scope reviewer

  3. production-shaped test reviewer

    • 現在の
      test_owner_reaction_not_planned_gate_production_shaped.py
      がどこを bypass しているか確認する
    • producer payload を Python test code が直接 consumer に注入する構造を廃止し、
      real canonical entrypoint を入口にした最小 E2E test を設計する

SubAgent は nested SubAgent を起動しないこと。

全 SubAgent の作業完了を必ず待ってから main orchestrator が統合判断してください。
一部だけ返った状態で実装を開始しないでください。

Scope reframe が必要な場合

独立調査で comment の P0 が再現し、共有 infra transport の変更が不可避なら、コード変更より先に Issue #2689 の live contract を canonical issue-editing path で最小修正してください。

raw な無制御 mutation は避け、repository の既存 issue-editing workflow / guard に従ってください。

最低限、Issue #2689 の以下の矛盾を解消してください。

  • 「既存 Allowed Paths のみで production 到達可能」という前提
  • command_registry.py / skill_runtime_exec.py / skill_runtime_command_policy.py が絶対 Out of Scope という記述
  • AC6 の「production-shaped」の定義

AC6 は少なくとも次の chain を実際に通すことを要求する内容へ修正してください。

real skill_runtime_exec.py
→ exact command parser / policy
→ command_registry.render_command()
→ run_refinement_preflight.py CLI main()
→ cli_known_context materialization
→ run_preflight()
→ _classify_heavy_mutation_gate_with_fresh_owner_reaction()
→ fresh owner_reaction_decision.py subprocess
→ _classify_heavy_mutation_gate()

fake/stub は GitHub network boundary に限定して構いません。

Issue body を広範囲に書き換えず、今回必要な transport gap の修正だけに限定してください。

実装修正の優先順位

OWNER comment の finding を以下の順で扱ってください。

P0-1: canonical production transport

canonical preflight invocation から必要 context が実際に run_preflight() まで届くようにしてください。

mutation_category や owner reaction inputs を test-only hand-crafted dict で注入するだけでは不可です。

可能なら明示的 transport を使い、comment metadata などから暗黙推論しないでください。

特に:

  • mutation intent/category
  • stable owner user ID
  • preview binding file

の provenance を曖昧にしないこと。

今回開放する mutation category は引き続き not_planned のみです。

close
replacement_issue_creation
dependency_removal
parent_child_change

は fail-closed のまま維持してください。

generic authorization framework や ledger/TTL などは追加しないでください。

P0-2: false-green test の修正

現在の production-shaped test のように、

producer_payload
→ test code
→ _is_approved_owner_reaction_not_planned_decision()
→ _classify_heavy_mutation_gate()

と手動接続してはいけません。

上述の canonical production chain を real subprocess entrypoint から通してください。

既存 owner_reaction_dispatch_fixture.py / fake-gh infrastructure は可能な限り再利用し、新規大規模 harness を作らないでください。

P1: non-zero subprocess exit

_run_owner_reaction_decision_fresh() は check=False の child result の returncode を明示確認してください。

non-zero + parseable structured JSON でも transport success として扱わず fail-closed にしてください。

少なくとも

  • returncode != 0
  • stdout に parseable JSON が存在

する regression test を追加してください。

P2: schema identity

低コストで可能なので、

decision["schema"] == "OWNER_REACTION_DECISION_RESULT_V1"

または実際の canonical schema identity に対応する等価チェックを predicate boundary に追加してください。

既存 schema validator frameworkを新設する必要はありません。

守るべき既存設計

以下は壊さないでください。

  • not_planned 限定
  • selected_option_metadata.operation == "close_not_planned"
  • exact target binding
  • same operation / different target を別 decision として扱う
  • selected を approved_by_trusted_anchor に変換しない
  • trusted-anchor authority と owner-reaction authority を分離する
  • owner reaction は gate 評価直前に fresh readback
  • saved/cached authorization result を再利用しない
  • 他の heavy mutation categories は fail-closed

impl-review-loop の実行

scope contract が coherent になったら、.claude/skills/impl-review-loop/SKILL.md を正本として通常ループを実行してください。

対象 PR #2697 を再利用し、新規 PR を作らないこと。

target comment の blocker を fix_delta として Step 1 implementation-worker に渡してください。

各 iteration で:

  1. implementation-worker
  2. test-runner
  3. pr-reviewer
  4. Step 5 canonical routing

を実施してください。

各 SubAgent の完了を必ず待つこと。

SubAgent の散文だけで判断せず、skill が要求する structured result を保持してください。

current-head binding を必ず確認し、実装後に head が変わった場合は古い review verdict を再利用しないでください。

REQUEST_CHANGES なら追加承認なしで次 iteration に進んでください。

BLOCKED / UNSTABLE / DRAFT や advisory snapshot warning だけを理由に human escalation しないで、skill の canonical routing に従ってください。

実 Git conflict、secret/credential 判断、明示的な human stop、max_iterations 等の skill 上の真正 hard stop が発生した場合だけ停止してください。

Verification

Issue #2689 の AC/VC を fresh contract に基づいて再評価してください。

最低でも:

  • focused owner-reaction gate tests
  • canonical production-shaped E2E
  • credentialless transport regression
  • owner reaction dispatch / failure-boundary regressions
  • heavy mutation gate regressions
  • 変更した skill-runtime exact-command parser / registry / executor の関連 tests

を実行してください。

無関係な全リポジトリ test suite を機械的に増やすより、今回変更した production boundary を直接検証する focused tests を優先してください。

既知の pre-existing failure と今回導入した failure を明確に分離してください。

完了条件

以下を全て満たすまで自律継続してください。

  • target comment の P0 2件が production path 上で解消
  • P1 解消
  • P2 の軽量 schema identity check も実施
  • AC6 が test-code handoff ではなく canonical transport を通る
  • relevant tests PASS
  • pr-reviewer の fresh current-head verdict が APPROVE
  • blockers が空
  • live mergeability / CI を impl-review-loop の canonical Step 5 で評価
  • autonomy-policy validator 等、skill が termination 前に要求する gate を通過
  • IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready 相当のマージ直前状態に到達

PR の merge はしないでください。

最後に、実際に変更した Issue contract、変更ファイル、最終 head SHA、テスト結果、review verdict、残存 warning、mergeability を簡潔に報告してください。

ポイントは、P0 の修正そのものより先に #2689 の「共有 infra は変更禁止」という契約矛盾を解消させることです。これを入れないと、実装できても impl-review-loop の Allowed Paths gate で再度 REQUEST_CHANGES になる可能性が高いです。

squne121 and others added 5 commits September 21, 2026 14:37
… false-green E2E repair (#2689)

PR #2697 review fix_delta (comment #5755475318):
- P0-1: add --mutation-category/--owner-user-id/--preview-binding-file to
  run_refinement_preflight.py's main(), wired through command_registry.py's
  preflight.run.with_human_context / contract_update.run.with_human_context
  and skill_runtime_command_policy.py's exact command parser, so the
  not_planned heavy mutation gate is reachable from the real production
  dispatch chain (previously only exercisable via hand-crafted known_context).
- P0-2: replace the false-green production-shaped test with a real E2E that
  launches run_refinement_preflight.py as a genuine subprocess (fixture-mode
  outer read, fake-gh-backed nested owner_reaction_decision.py subprocess)
  and observes the gate's decision via the real planner_input.json artifact
  -- no test-code manual bridging of producer/consumer.
- P1: _run_owner_reaction_decision_fresh() now fails closed on any non-zero
  subprocess exit, even when stdout happens to parse as JSON.
- P2: add a lightweight OWNER_REACTION_DECISION_RESULT_V1 schema-identity
  check to the same function.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…on-heavy-mutation-gate' into worktree-issue-2689-owner-reaction-heavy-mutation-gate
…tion-gate transport triple (#2689 fix_delta, PR #2697 Blocker 2)

pr-reviewer noted no existing test starts skill_runtime_exec.py as a real
subprocess with --mutation-category/--owner-user-id/--preview-binding-file;
reuse the existing _install_real_contract_update_fixture() fixture to prove
the triple is accepted and correctly reaches run_refinement_preflight.py's
heavy mutation gate.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121
squne121 marked this pull request as ready for review September 21, 2026 07:34
@squne121
squne121 merged commit 8f590b9 into main Sep 21, 2026
46 checks passed
@squne121
squne121 deleted the worktree-issue-2689-owner-reaction-heavy-mutation-gate branch September 21, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: owner_reaction_decision.py の出力を既存 heavy mutation gate へ統合する(#1975 の Out of Scope)

1 participant