Repository navigation
feat: route_canonical_step2_result() を _cmd_produce() の全 stdout JSON 出力経路へ配線する - #2391
Conversation
…出力経路へ配線する (#2389) canonical Step 2 の routing authority を `canonical_step2_route`(produce 自身が計算する route_canonical_step2_result() の戻り値)へ一本化し、 orchestrator が status/verdict/next_action から独自に再計算しなくて済む 状態にする。あわせて approve+proceed の戻り値を STEP_4_5 から STEP_2_5 へ 修正し、Step 2.5 semantic design review applicability 判定を迂回しない ようにする。既知の producer error_code(reviewer_transport_environment_failure / artifact_readback_failed)は STEP_5_HUMAN_JUDGMENT_REQUIRED として扱い、 それ以外(body fetch 失敗・VC budget 超過を含む)は従来通り fail-closed の まま据え置く。 - run_root_review_pipeline.py: STEP_2_5 定数、_emit_produce_result() ヘルパー 追加し、_cmd_produce() の全5出力経路をこれに統一 - test_root_review_canonical_delivery.py: STEP_4_5 期待値を STEP_2_5 へ更新 - test_canonical_step2_route_wiring.py: 新規追加、配線・route変更・エラー系 routeの区別を検証 - issue-refinement-loop/SKILL.md, review-issue/SKILL.md, command_registry.py: canonical_step2_route を唯一の routing authority として読む旨に更新 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2391/ The preview will be removed when this PR is closed. |
PR Review (pr-review-judge)Verdict: APPROVE Linked Issue #2389 の live contract と PR diff・AC1-AC7・Allowed Paths・CI を独立検証しました。
Blockers: なし verdict: APPROVE
reviewed_head_sha: "43fd45676f888df7904f667ec7c18e5cdf6abe1f"
blockers: []
warnings:
- "merge_state_status: BLOCKED(mergeable: MERGEABLE)。branch protection required context 'python-test' が現行ワークフローのcheck名と一致しない既存repo設定問題と見られ、本PRのdiffに起因しない。"
- "python-test-core / e2e-core / e2e-responsive-matrix はレビュー時点でIN_PROGRESSだったが、branch protection required contextには含まれていない。" |
敵対的レビュー結果判定REQUEST_CHANGES — 現状のままではマージ非推奨です。 レビュー対象は draft の PR #2391、head は 方向性には賛成です。
しかし、routeを一本化した一方で、そのrouteへ入力されるproducer契約が壊れたままです。 P0-1:
|
…ail-closed に統一する OWNER PR #2391 敵対的レビュー (P0-2, P1-1) を反映。result/compact_result が Mapping でない場合は例外を送出せず fail_closed_environment_or_integrity_failure を返すようにし、needs-fix + human_judgment_required の exact な組合せのみを step_5_human_judgment_required とする。status: input_or_runtime_error は 既知/未知の error_code を問わず fail-closed とし、Issue #2054 の transport_status: environment_failure / semantic_verdict: null 分離契約を supersede せず preserve する。
…ing (sync with main via Update branch)
fix_delta: P0-2 / P1-1 対応(head
|
PR Review (pr-review-judge) — fix_delta後の再レビューVerdict: APPROVE OWNERレビュー(issuecomment-5461056774)で指摘されたP0-1/P0-2/P1-1について、head
Blockers: なし verdict: APPROVE
reviewed_head_sha: "690f33423af6bf397d82aaab92a28d6c03405a40"
blockers: []
warnings:
- "P0-1(producer到達可能性)は本Issueの意図的スコープ外(reviewer_transport.pyはAllowed Paths外)。STEP_5_HUMAN_JUDGMENT_REQUIRED分岐は現状本番producerからは到達不能なまま。follow-up issue化が望ましい。" |
…ようにする (#2397) reviewer_transport.py の build_compact_v2() に optional な failure_class 引数を追加し、merged_review_result.failure_class == contract_readiness_human_judgment (かつ verdict == needs-fix) の場合に NEXT_ACTION: human_judgment_required を持つ V2 compact を生成できるようにした。 validate_compact_v2() も next_action の許容値域を proceed | request_changes | human_judgment_required の3値に拡張し、 inconsistent な approve + human_judgment_required の組合せは引き続き fail-closed で拒否する。 これにより run_root_review_pipeline.route_canonical_step2_result() が 判定する step_5_human_judgment_required 分岐が実際の producer 出力から 到達可能になる (PR #2391 owner P0-1 の follow-up)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…erator intervention route を追加する (#2398) * feat: build_compact_v2() が human_judgment_required next_action を生成できるようにする (#2397) reviewer_transport.py の build_compact_v2() に optional な failure_class 引数を追加し、merged_review_result.failure_class == contract_readiness_human_judgment (かつ verdict == needs-fix) の場合に NEXT_ACTION: human_judgment_required を持つ V2 compact を生成できるようにした。 validate_compact_v2() も next_action の許容値域を proceed | request_changes | human_judgment_required の3値に拡張し、 inconsistent な approve + human_judgment_required の組合せは引き続き fail-closed で拒否する。 これにより run_root_review_pipeline.route_canonical_step2_result() が 判定する step_5_human_judgment_required 分岐が実際の producer 出力から 到達可能になる (PR #2391 owner P0-1 の follow-up)。 Co-Authored-By: Claude Sonnet 5 <[email protected]> * revert: 旧設計(V2 wire三値化)実装を撤去し main と byte-identical に戻す (#2397) Issue #2397 の reframe により、reviewer_transport.py への failure_class 引数追加・NEXT_ACTION 三値化・test_review_compact_v2_human_judgment.py の新規追加は不要になったため撤去する。新設計は route_canonical_step2_result() 側で failure_class を判定する。 * feat: route_canonical_step2_result() に verified failure_class ベースの operator intervention route を追加する (#2397) merged_review_result.failure_class == "contract_readiness_human_judgment" (env/tool/timeout/unknown 分類等、Issue 本文書き換えでは解消しない operator 起因の readiness 状態)を持つ needs-fix + request_changes の payload を、 新設の STEP_5_OPERATOR_INTERVENTION_REQUIRED route へ送る。Compact V2 wire (NEXT_ACTION の proceed | request_changes 二値契約)は変更しない。 OWNER 敵対的レビュー(P0-1/P0-2/P0-3、issues/2397#issuecomment-5461878398) の指摘に従い、前版 Issue の V2 wire 三値化案(reviewer_transport.py への failure_class 引数追加・NEXT_ACTION 三値許容化)は撤去し、root-owned route_canonical_step2_result() 側で判定する設計に作り直した。 * fix: termination-policy.md の見出しを Japanese Check 準拠に修正 (#2397) CI の PR Body Japanese Check(changed markdown 全体検査)が新設見出し 「## `canonical_step2_route: ...` の termination payload(#2397)」を prose block として検出し、日本語比率不足で fail していたため、見出し文言 に日本語を追加して修正した(意味・内容は変更なし)。 * fix: test_operator_intervention_route.py の E501 (ruff) を noqa で解消 (#2397) CI の python-test-core ruff check が、Issue #2397 の Verification Commands に必須の長い test 関数名(pytest -k 選択子として exact match が要求される) に対し E501 (line too long) を報告していたため、既存コードベースの慣例 (# noqa: E501)に従い抑制した。関数名・テスト内容は変更しない。 * fix: command_not_allowed の誤分類を修正し operator intervention route の Scope Delta を反映する (#2397) OWNER 敵対的レビュー (PR #2398, #2398 (comment)) の P0-1/P1-1/P1-2/P2-1 を反映する fix_delta。 - P0-1 (blocking): contract_readiness_check.py の _PREFLIGHT_CATEGORY_TO_READINESS に command_not_allowed -> needs_fix を 追加。body-fixable な command_not_allowed が human_judgment (延いては operator intervention route) へ誤ってフォールバックする回帰を修正。 - 新規テストファイル test_operator_intervention_route_scope_delta.py で AC9-AC12 を実 _cmd_produce() 経路で検証 (command_not_allowed -> step_4 回帰、真に operator-only な fixture -> step_5_operator_intervention_required、 canonical_step2_disposition の付与)。 - 既存 test_operator_intervention_route.py の operator-only fixture を command_not_allowed から真の operator-only 状態 (jq + 存在しないパス -> unknown 分類 -> human_judgment 直行) へ差し替え (関数名は無変更)。 - run_root_review_pipeline.py に build_canonical_step2_disposition() を 追加し、_cmd_produce() の全 stdout JSON 出力経路 (_emit_produce_result()) に canonical_step2_disposition フィールドを配線 (AC12)。 - route_canonical_step2_result() / check_issue_contract.py の docstring から、撤回済みの「compact wire 側で failure_class から NEXT_ACTION: human_judgment_required を導出する」設計記述を除去し、 現行の root-owned route 設計 (merged_review_result.failure_class を 直接参照) の説明へ更新 (P2-1)。 - issue-refinement-loop/SKILL.md の Step 2 routing table と直後の要約に step_5_operator_intervention_required を独立した5番目の分岐として 明記 (AC13)。 既知の未解決事項: .claude/skills/review-issue/tests/test_check_issue_contract.py (Allowed Paths 外) の test_human_judgment_not_collapsed_to_needs_fix が command_not_allowed フィクスチャの旧挙動 (human_judgment/blocked) を前提と しており、本修正後は status: needs_fix になるため fail する。この 契約テストの期待値更新には Allowed Paths 拡張の Scope Delta が必要。 * fix: SKILL.md の thin entrypoint line budget (500行) 超過を解消する (#2397) 前コミットの Step 2 routing table 要約追記で SKILL.md が 505 行になり test_skill_md_is_under_500_lines / test_skill_md_stays_within_line_budget が fail していた。review phase routing summary を圧縮し 499 行に収める (内容は変更せず改行のみ整理)。 * fix: command_not_allowed 誤分類回帰で fail する human_judgment fixture を差し替える (#2397) CI(python-test-core)で確認された既存テスト退行を修正する。 `contract_readiness_check.py` の `_PREFLIGHT_CATEGORY_TO_READINESS` に `command_not_allowed: needs_fix` を追加した(P0-1修正、意図的な挙動変更)結果、 `test_check_issue_contract.py::TestContractReadinessExecuteIntegration:: test_human_judgment_not_collapsed_to_needs_fix` が fail していた。 このテストの fixture (`_HUMAN_JUDGMENT_ISSUE_CONTENT`) は preflight の 許可コマンド一覧に無い `loop-protocol-nonexistent-tool-xyz-abc` を VC に使っており、 これは実行前に `command_not_allowed` として拒否される(body-fixable な状態、 Issue #2397 Scope Delta AC9 の意図どおり needs_fix になるべき状態)。 fixture を、Issue #2397 の新規テスト (`test_operator_intervention_route.py` / `test_operator_intervention_route_scope_delta.py`) と同じパターンである `jq '.' fixture/<存在しないパス>.json` に差し替える。`jq` は許可コマンドのため 実際に実行されるが、参照先パスが存在しないため exit code 2 で失敗し、 `classify_result()` の既知パターンに一致せず `category: unknown` に分類される。 `unknown` は `_PREFLIGHT_CATEGORY_TO_READINESS` で human_judgment のまま維持される genuine operator-only な状態であり、テスト関数名・「human_judgment に collapse されないこと」を検証するアサーションの意図は変更していない。 Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: AC11 operator-only fixture を決定論的な env_missing_dep へ差し替え、Step 5 分岐説明を修正する Issue #2397 Scope Delta iteration 3(OWNER PR #2398 敵対的レビュー、3回目、 #2398 (comment)) の P0-1/P1-1/P1-2/P1-3 を反映する fix_delta。 - P0-1 (AC14): test_operator_intervention_route_scope_delta.py の `test_genuinely_operator_only_fixture_routes_to_operator_intervention` の fixture を、`jq` を存在しない path へ向ける `unknown` catch-all 分類 トリックから、preflight の real subprocess execution boundary を PATH シムで monkeypatch し決定論的に `category: env_missing_dep` を発生させる 方式へ差し替えた。壊れやすい `fixture/e2e_produce_operator_intervention_scope_delta_unknown.json` 参照は削除。テスト関数名・アサーション内容は無変更。 - P1-1 (AC15): issue-refinement-loop/SKILL.md に、Step 5 operator intervention route の終了処理が `canonical_step2_disposition` の `termination_reason` / `termination_cause` をそのまま使用し独自に 再導出しないことを明記した。 - P1-2 (AC16): issue-refinement-loop/SKILL.md の `step_5_human_judgment_required` の説明を、現行 Compact V2 producer からは生成されない defensive/legacy route である旨に修正した。 - P1-3 (AC17): run_root_review_pipeline.py の `FAILURE_CLASS_CONTRACT_READINESS_HUMAN_JUDGMENT` に、route-critical な 既知 failure_class 値の single source of truth であることを明示する コメントを追加した。 Closes #2397 --------- Co-authored-by: Test <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
run_root_review_pipeline.pyの_cmd_produce()が持つ全 5 つの stdout JSON 出力経路(成功時 / body fetch 失敗時 / VC budget エラー時 / transport failure 時 / artifact readback failure 時)に、route_canonical_step2_result()の呼び出し結果をトップレベルcanonical_step2_routeフィールドとして配線した(新設ヘルパー_emit_produce_result()に一本化)。route_canonical_step2_result()自体のロジックも修正:status: ok+verdict: approve+next_action: proceedの場合、旧来のSTEP_4_5(step_4_5)ではなく新設のSTEP_2_5(step_2_5)を返すようにし、Step 2.5 semantic design review applicability 判定を迂回しないようにした。status: input_or_runtime_errorかつ既知の構造化error_code(reviewer_transport_environment_failure/artifact_readback_failed)はstep_5_human_judgment_requiredとして扱い、それ以外(body fetch 失敗・VC budget 超過を含む、Issue 実装: route_canonical_step2_result() を CLI / _cmd_produce() の出力に配線する #2389 の Out of Scope)は従来通りfail_closed_environment_or_integrity_failureのまま据え置いた。issue-refinement-loop/SKILL.md/review-issue/SKILL.md/command_registry.pyの canonical Step 2 consumer 記述を、canonical_step2_routeを唯一の routing authority として読む旨に更新した。test_root_review_canonical_delivery.py)のSTEP_4_5期待値をSTEP_2_5へ更新し、新規テストtest_canonical_step2_route_wiring.pyを追加して配線・route 変更・エラー系 route の区別を検証した。本 PR は Closes #2389 として Issue #2389 をクローズする。
Checks
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_canonical_step2_route_wiring.py -v— 12 passed(AC1-AC4 該当の-kフィルタもすべて個別 PASS 確認済み)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_root_review_canonical_delivery.py -q— 24 passed(AC5)rg -n "canonical_step2_route" .claude/skills/issue-refinement-loop/SKILL.md .claude/skills/review-issue/SKILL.md .claude/skills/issue-refinement-loop/scripts/command_registry.py— 3ファイルすべてに出現(AC6)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_transport_e2e.py .claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_readback_v2_ssot.py -q— 57 passed(AC7、既存 compact/artifact schema・inner retry・readback gate は無変更のまま PASS)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q— 1797 passed, 3 failed(既存 baseline でも同様に fail するtest_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch3件のみで、本 PR の変更(コメント追記のみ)とは無関係。git stashした baseline でも同じ3件が同じ理由で fail することを確認済み)uv run --locked python3 .claude/skills/create-issue/scripts/validate_japanese_content.py --file .claude/skills/issue-refinement-loop/SKILL.md --verbose/ 同review-issue/SKILL.md— 両方 PASSpnpm typecheck/pnpm lint/pnpm test/pnpm build— 本 PR は TypeScript/JS フロントエンドファイルを一切変更しないため実行を省略した(Allowed Paths はすべて.claude/skills/**配下の Python スクリプト・テスト・Markdown のみ)Schema Change Applicability
_cmd_produce()の stdout JSON(consumer 契約:issue-refinement-loopcanonical Step 2 orchestrator)に新規トップレベルフィールドcanonical_step2_routeを追加し、かつroute_canonical_step2_result()の戻り値そのものを approve+proceed ケースでstep_4_5からstep_2_5へ変更したため、schema change として扱う。Schema Consumer Inventory
.claude/skills/issue-refinement-loop/SKILL.mdcanonical_step2_route唯一の routing authority として読む旨に更新。approve のターゲットを Step 2.5 へ修正.claude/skills/review-issue/SKILL.mdcanonical_step2_routeが唯一の routing authority である旨を追記.claude/skills/issue-refinement-loop/scripts/command_registry.pyroot_review_pipeline.produceコマンド定義のコメントにcanonical_step2_route配線を追記(コメントのみ、実行時契約に変更なし).claude/skills/issue-refinement-loop/tests/test_root_review_canonical_delivery.pySTEP_4_5を期待していた既存 assertion 2箇所をSTEP_2_5へ更新.claude/skills/issue-refinement-loop/tests/test_canonical_step2_route_wiring.py.claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.pyroute_canonical_step2_result()/canonical_step2_routeを consume しない別系統のスクリプト(rewrite phase 後の next-action 決定専用)。呼び出し規約は本 Issue のスコープ外で変更していないSafety Claim Matrix
STEP_4_5からSTEP_2_5へ変わるが、Step 2.5 がsemantic_review_applicable: falseの場合は自身が直接 Step 4.5 へ進めるため、最終的な到達先の集合は変化しない(Step 2.5 の判定を迂回できなくなるだけ)test_route_canonical_step2_result_approve_routes_to_step_2_5/ 既存test_given_real_produce_output_when_routed_through_pure_router_end_to_end_then_no_agent_handoff_occurs(本PRで STEP_2_5 期待値へ更新し PASS)input_or_runtime_errorは今回変更せず fail-closed のまま据え置いた(Issue #2389 Out of Scope の明示要求)test_produce_body_fetch_failure_stdout_top_level_field_present/test_produce_vc_budget_error_stdout_top_level_field_present(いずれもcanonical_step2_route == fail_closed_environment_or_integrity_failureを確認)reviewer_transport_environment_failure/artifact_readback_failed)以外の未知error_codeは fail-closed のままであり、新しい human-judgment 昇格経路が誤って未知エラーまで拾わないtest_route_canonical_step2_result_producer_error_route_distinction(unrecognized_error_code/missing_error_codeの両方で fail-closed を確認)_cmd_produce()の戻り値型(既存の整数 exit code)・main()/sys.exit()の契約は変更していないreturn 0/return 2は本PRで変更なし(git diffで確認可能)。既存test_root_review_pipeline_readback_v2_ssot.py/test_reviewer_transport_e2e.py57件 PASSNotes
immediate)は、実 CLI(_cmd_produce())を実際に起動する production-shaped pytest(test_canonical_step2_route_wiring.py/test_root_review_canonical_delivery.py/test_reviewer_transport_e2e.py/test_root_review_pipeline_readback_v2_ssot.py)で実施し、fallback・SKIP は使用していない。STEP_4_5("step_4_5")定数自体は削除していない(Issue 実装: route_canonical_step2_result() を CLI / _cmd_produce() の出力に配線する #2389 のスコープは「approve+proceed の戻り値」の変更のみであり、定数の削除・rename は要求されていない)。test_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatchの 3 件は本 PR 変更前の baseline(git stashで本PRの差分を退避した状態)でも同一理由で fail することを確認済みであり、本 PR のスコープ外の既存環境依存の失敗である。