Skip to content

実装: LOOP_VERDICT_V2 契約の producer/consumer/publisher atomic cutover を行う #1857

Closed as not planned

Description

@squne121

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

Parent Issue

#1732

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

Remaining Parent Gaps

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_ready cross-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: COMMENT const、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

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_ready cross-field invariant・update_branch.expected_head_sha == reviewed_head_sha・action kind × executor × skill matrix・allowed_paths_gate_source producer 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_impl

Allowed 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)。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 29, 2026
  2. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    #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.publish command 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で対応する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions