Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1732"
goal_ref: "LOOP_VERDICT_V2 の producer(pr-review-judge)・consumer(impl-review-loop の route_loop_verdict_v2.py)・controlled publisher が同一 schema/validator を import し、duplicate key/不正 enum を fail-closed で拒否する単一契約へ切替える"
change_kind: mixedParent Issue
Blocking Dependency
なし。schema cutover は #1745(permission contract)と独立に実装できる。
Parent Goal Ref
- Goal: Agent/Skill 間で重複する command/routing/schema の二重所有を解消する
- Desired Destination:
LOOP_VERDICT_V2の machine schema が単一正本として存在し、producer/consumer/controlled publisher が同一 validator を共有している
Current Validated Scope
-
.claude/skills/pr-review-judge/references/loop-verdict-v2-schema.mdはrequired_auto_actionsキーを同一LOOP_VERDICT_V2マッピング内で 2 回定義しており、YAML 後勝ちの split-brain 状態にある -
.claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.pyはclassify_auto_actions/build_loop_verdict_v2を production module から import せず、テスト内で再実装している -
production consumer
.claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.py(501 行)はrequired_auto_actions、V1 field、mergeability、BEHIND invariant、action matrix を独自 Python 実装で検証しており、JSON Schema の共通 validator を import していない -
controlled publisher 側の mutation exec は
scripts/agent-guards/controlled_skill_mutation_exec.py/scripts/agent-ops/pr_review_marker_archive_exec.pyがpr_review.publishcommand id を所有する -
schemas/catalog.yaml:303にschema_id: "LOOP_VERDICT"(LOOP_VERDICT_V2ではない)のエントリが存在し、definition path・version が producer 側の実体と同期していない -
Scope Collision preflight(
check_issue_overlap.py): decisionoverlap_requires_comment(policy_class C1)。.claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.pyが 実装: impl-review-loop production routerで mergeable と merge_state_status を分離し、conflict・unknown routingを正規化する #1853(impl-review-loop production router の mergeable/merge_state_status 分離)と overlapping_paths として検出された。non_conflict_reason: 本 Issue は同ファイルへの schema import 切替(loop_verdict_contract.pyの import・独自 schema 検証ロジック除去)のみを扱い、実装: impl-review-loop production routerで mergeable と merge_state_status を分離し、conflict・unknown routingを正規化する #1853 が扱う mergeability semantic routing(mergeable/merge_state_status分離)自体には触れない。両 Issue が並行 OPEN の場合はマージ順で衝突を吸収し、後発側が rebase する -
schemas/catalog.yamlは複数の schema 登録 Issue(実装: commit/PR 作成後の target head に対し pairwise_merge_conflict を SHA-bound で観測する PAIRWISE_MERGE_OBSERVATION_V1 producer を追加する #1792/実装: schemas/catalog.yaml の temp_residue schema required_test_commands に専用 command_id を登録する #1433/実装: repo_temp_folder_advice schema を catalog に登録する #1418/実装: schema-governance.md の Initial Known Schemas を catalog から生成するスクリプト(#131 FU-5) #521/実装: schemas/catalog.yaml と schema-consistency CI を導入し機械可読な schema カタログ管理を確立する #166 等)が触れる共有ファイルであり、本 Issue はLOOP_VERDICT_V2エントリの definition path/version 同期のみを扱う
Remaining Parent Gaps
pr-reviewerAgent 本文の薄型化・preload 追加は Child A1(実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744)が扱う- context budget の数値検証・distribution scope 明示は Child A2(follow-up)が扱う
Outcome
.claude/skills/pr-review-judge/schemas/loop-verdict-v2.schema.json(JSON Schema Draft 2020-12)と、共有ライブラリ .claude/skills/pr-review-judge/scripts/loop_verdict_contract.py(strict YAML loader → JSON Schema → semantic invariant validator の 5 段パイプライン)が新設され、producer 側 validate_loop_verdict_v2.py、production consumer .claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.py、controlled publisher dry-run のいずれもが同一ライブラリを import し、8 種の golden fixture(APPROVE+CLEAN+no actions/APPROVE+BEHIND+valid update_branch/APPROVE+BEHIND+missing action/REQUEST_CHANGES/stale expected_head_sha/multiple actions/body-only action while BEHIND/unknown action-executor-skill)で producer/consumer/publisher が同一の受理・拒否結果を返す状態。REVIEW_AGENT_RESULT_V1 / LOOP_VERDICT_V2 / PR_REVIEW_PUBLISH_REQUEST_V1 が discriminated union として別 schema に分離されている状態。
In Scope
.claude/skills/pr-review-judge/schemas/loop-verdict-v2.schema.jsonを新設し、JSON Schema Draft 2020-12 でLOOP_VERDICT_V2の必須フィールド・enum・merge_readycross-field invariant・update_branch.expected_head_sha == reviewed_head_sha・action kind × executor × skill の閉じた matrix・allowed_paths_gate_sourceの producer identity・unknown enum/field 拒否を定義する.claude/skills/pr-review-judge/scripts/loop_verdict_contract.pyを新設し、raw YAML bytes → duplicate-key rejecting strict YAML loader → normalized JSON instance → JSON Schema Draft 2020-12 → semantic invariant validator → typed verdict objectの 5 段パイプラインを実装する.claude/skills/pr-review-judge/scripts/validate_loop_verdict_v2.pyを上記共有ライブラリの thin wrapper へ書き換える.claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.pyの独自 schema/routing 検証ロジックをloop_verdict_contract.pyの import へ置き換える(dispatch の semantic routing 自体は本 Issue の責務外で維持する)REVIEW_AGENT_RESULT_V1(terminal_state: completed | insufficient_context | blocked,verdict: <LOOP_VERDICT_V2 | null>,reason_code: <string | null>)とLOOP_VERDICT_V2(semantic judgment only)とPR_REVIEW_PUBLISH_REQUEST_V1(event: COMMENTconst、trusted publisher owner)を別 schema として分離し、terminal_state=insufficient_context|blockedの場合にverdictを必須にしない discriminated union(oneOf/if-then)を JSON Schema で表現する.claude/skills/pr-review-judge/references/loop-verdict-v2-schema.mdの duplicate key(required_auto_actionsの二重定義)を解消し、人間向け説明へ降格するschemas/catalog.yamlのLOOP_VERDICTエントリをLOOP_VERDICT_V2の definition path/schema ID/version/consumer inventory と同期させる.claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.pyを production module import 形式に書き換え、8 種 golden fixture を追加する。duplicate-key negative fixture は生 YAML bytes として保持する.claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2_schema_file.pyを新設し、schema file 自体の duplicate-key/不正 enum 拒否を検証する.claude/skills/impl-review-loop/scripts/tests/配下に production consumer 向け golden fixture テストを追加する(8 種を producer と共有)
Out of Scope
pr-reviewerAgent 本文の薄型化・skills: [pr-review-judge]preload 追加(Child A1/実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744)- context budget の数値判定基準・distribution scope 明示・
pr-reviewer-lite移行判断(Child A2) .claude/settings.jsonのRead(**/.claude/**)deny rule 再設計(実装: Skill references/ の read permission と Agent/Skill 契約 strict validator を追加する #1745)- controlled publisher の hash/identity/TOCTOU gate の再実装(既存実装を維持し、import 元を切替えるのみ)
- semantic verdict 判断ロジック自体(APPROVE/REQUEST_CHANGES の判定基準)の変更
Runtime Verification Applicability
runtime_verification_applicability:
decision: not_applicable
reason: >-
本 Issue は producer/consumer/publisher の schema 検証ライブラリ切替であり、
fresh Claude Code session での preload/permission runtime smoke を必要としない。
静的 pytest(production module import・golden fixture 一致検証)で完結する。
applicable_acs: []Acceptance Criteria
- AC1:
.claude/skills/pr-review-judge/schemas/loop-verdict-v2.schema.jsonが JSON Schema Draft 2020-12 として valid であり、required_auto_actionsの duplicate key を含む生 YAML bytes fixture を loader 段階で拒否する - AC2:
loop_verdict_contract.pyの 5 段パイプラインがmerge_readycross-field invariant・update_branch.expected_head_sha == reviewed_head_sha・action kind × executor × skill matrix・allowed_paths_gate_sourceproducer identity を semantic invariant validator 段で検証する - AC3: production consumer
.claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.pyがloop_verdict_contract.pyを import し、独自 schema 検証ロジックを保持しない - AC4: 8 種 golden fixture(APPROVE+CLEAN+no actions/APPROVE+BEHIND+valid update_branch/APPROVE+BEHIND+missing action/REQUEST_CHANGES/stale expected_head_sha/multiple actions/body-only action while BEHIND/unknown action-executor-skill)が producer validator と production consumer の両方で同一の受理・拒否結果になる
- AC5:
REVIEW_AGENT_RESULT_V1/LOOP_VERDICT_V2/PR_REVIEW_PUBLISH_REQUEST_V1が別 schema として定義され、terminal_state=insufficient_context|blockedのときverdictが required に含まれない discriminated union が schema 上で検証できる - AC6:
schemas/catalog.yamlのLOOP_VERDICT_V2エントリの definition path/schema ID/version が producer/consumer 実体と一致する - AC7:
.claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.pyがclassify_auto_actions/build_loop_verdict_v2を production module から import する形式であり、テスト内 shadow 実装を含まない
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2_schema_file.py -q -k test_schema_file_rejects_duplicate_key_raw_yaml_bytes# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.py -q -k test_semantic_invariant_validator_checks_expected_head_sha_and_action_matrix# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/scripts/tests/test_route_loop_verdict_v2_shared_contract.py -q -k test_route_loop_verdict_v2_imports_loop_verdict_contract# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/scripts/tests/test_route_loop_verdict_v2_shared_contract.py -q -k test_golden_fixtures_match_producer_and_consumer# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2_schema_file.py -q -k test_terminal_state_blocked_does_not_require_verdict# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_schema_catalog_sync.py -q -k test_loop_verdict_v2_schema_id_version_definition_path_synced# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.py -q -k test_test_module_imports_production_functions_not_shadow_implAllowed Paths
- .claude/skills/pr-review-judge/schemas/loop-verdict-v2.schema.json
- .claude/skills/pr-review-judge/scripts/loop_verdict_contract.py
- .claude/skills/pr-review-judge/scripts/validate_loop_verdict_v2.py
- .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2.py
- .claude/skills/pr-review-judge/scripts/tests/test_loop_verdict_v2_schema_file.py
- .claude/skills/pr-review-judge/references/loop-verdict-v2-schema.md
- .claude/skills/impl-review-loop/scripts/route_loop_verdict_v2.py
- .claude/skills/impl-review-loop/scripts/tests/test_route_loop_verdict_v2_shared_contract.py
- schemas/catalog.yaml
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- controlled publisher の hash/identity/TOCTOU gate の再実装が必要と判明した場合
- semantic verdict 判断ロジック(APPROVE/REQUEST_CHANGES 判定基準)自体の変更が必要と判明した場合
Required Skills
- Python
- pytest
- JSON Schema
Required Design References
- docs/dev/agent-skill-boundaries.md
Scope Delta(該当時のみ記載)
N/A
Delivery Rule
1 Issue = 1 PR を原則とする。worktree 上で作業し、Draft PR を既定とする。
Notes for Reviewer
親 Issue #1732 の Child A(旧 #1744)を OWNER の issue-contract-review(issuecomment-5123899691、verdict: REQUEST_CHANGES, classification: contract_reconstruction_required)に基づき再分割した Child A0(LOOP_VERDICT contract cutover)。
- OWNER 指摘 P0-2(AC5 の単一 schema 正本が production consumer
route_loop_verdict_v2.pyの Allowed Paths 外実装により実装不能)、P0-4(duplicate YAML key を JSON Schema のみで拒否する設計は成立せず、5 段パイプラインが必要)、P0-6(agent_terminal_state/LOOP_VERDICT_V2/PR_REVIEW_PUBLISH_REQUEST_V1の分離、discriminated union)、P1-4(production consumer 向け golden fixture 群を 8 ケースで用意)に対応する - 本 Issue は Child A1(実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744)の前提であり、Child A1 は本 Issue マージ後に着手する
- 兄弟 Issue: Child A1(実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744、pr-reviewer thin binding)/Child A2(follow-up、context/distribution evidence)/Child B0(実装: Skill references/ の read permission と Agent/Skill 契約 strict validator を追加する #1745、permission contract recovery)
Activity
squne121 commentedon Jul 31, 2026
#1860 Owner Decision(2026-07-30)に基づき、PR #1875(Issue #1873実装)が本Issueとsupersede関係にある旨を記録する。
PR #1875は以下を撤去済み:
LOOP_VERDICT_V2の producer 自己申告フィールド(merge_ready/required_auto_actions/allowed_paths_gate)pr_review.publishcommand id(controlled publisher)そのものroute_loop_verdict_v2.pyの strict schema検証ロジック(reviewer出力はverdict/reviewed_head_sha/blockers/warningsの最小conventionへ縮小)本Issueが目標とする「producer/consumer/publisherの単一schema・validator共有によるatomic cutover」は、対象のstrict schemaとcontrolled publisher自体がPR #1875で撤去されたため、前提が成立しなくなった。独立残存scopeは確認できなかったため、本Issueを
not plannedとしてclose する。PR #1875がmergeされた後に矛盾が確認された場合は、reopenまたは新規follow-up Issueで対応する。