Skip to content

実装: reviewer_claim_replay.py の taxonomy に unexpected_pass を追加する #1368

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "reviewer_claim_replay.py の taxonomy に unexpected_pass を追加し、deterministic evidence を明示する"
change_kind: code

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: issue-refinement-loop の Step 2a(reviewer_claim_replay.py arbitration)が、reviewer blocker を deterministic evidence で裁定できること
  • Desired Destination: .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1

Current Validated Scope

  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py の REVIEWER_CHECKER_TAXONOMY_V1 へ、baseline_vc_preflight.py の category == "unexpected_pass" を裏付けとする entry_id: unexpected_pass を追加する
  • unexpected_pass 用の replay 回帰テストを追加し、deterministic_fail_confirmed を確認する
  • --dump-taxonomy の検証と test_reviewer_claim_replay_taxonomy_parity.py を用いた drift 検知を Scope に含める

Remaining Parent Gaps

なし

Outcome

unexpected_pass のみが REVIEWER_CHECKER_TAXONOMY_V1 に反映され、reviewer_claim_replay.py が

  • readiness 側 (--readiness-result-file) で unexpected_pass を受けた場合に deterministic_fail_confirmed を返す
  • --vc-preflight-result-file で results[].category == "unexpected_pass" を受けた場合にも同等に deterministic 判定を返す

を満たすことを、既存回帰テスト+新規回帰テストで確認する。

unsafe_command / command_not_allowed は現時点では baseline 仕様の producer 変更を伴うため別Issueで対応し、本Issueは unexpected_pass に限定する。

In Scope

  • unexpected_pass 向けの entry_id を REVIEWER_CHECKER_TAXONOMY_V1 に追加する
  • unexpected_pass の readiness カテゴリ/ソースチェックを厳密化し、reviewer_claim_replay.py の replay 判定で deterministic_fail_confirmed になること
  • --vc-preflight-result-file 経由で、category == "unexpected_pass" を受け取った場合にも deterministic 判定が行われるようにする
  • rg の存在チェックに依存しない --dump-taxonomy + parity テストでの検証を追加する
  • safe scope として test_reviewer_claim_replay_taxonomy_parity.py を Allowed Paths に追加する

Out of Scope

Acceptance Criteria

  • AC1: --dump-taxonomy / REVIEWER_CHECKER_TAXONOMY_V1 に entry_id == "unexpected_pass" が存在し、readiness_category_source_check == "baseline_vc_preflight" が付与される
  • AC2: readiness 結果(unexpected_pass)を与えた replay が deterministic_fail_confirmed を返し、should_consume_iteration == true となる
  • AC3: --vc-preflight-result-file に results[].category == "unexpected_pass" を含む入力を与えた replay が deterministic_fail_confirmed を返す
  • AC4: test_reviewer_claim_replay.py が PASS
  • AC5: test_reviewer_claim_replay_taxonomy_parity.py が PASS
  • AC6: 本 Issue の safe scope 内で既存 tests / lint が PASS
  • AC7: unsafe_command / command_not_allowed の別対応方針(Issue)を明記する

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
# AC2
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
# AC3
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -v
# AC6
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
# AC7
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -v

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py
  • .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py

Runtime Verification Applicability

decision: immediate
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
execution_environment:
  cli_tools:
    - python3
    - uv
  auth_required: false
  network_required: false
skip_conditions:
  - "AC いずれかが `needs-fix`/`human_judgment` の場合は SKIP ではなく再審査"
fallback_policy:
  fallback_success_is_pass: false
  notes: "skip や fallback の成功を PASS として扱わない"
artifact_requirements:
  - "contract_readiness_check.py 出力"
  - "pytest output"

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • .claude/skills/issue-refinement-loop/SKILL.md#Step 2a Reviewer Claim Replay Arbitration

Scope Delta(任意)

N/A

Activity

  1. squne121 commented on Jul 7, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #1368 の方向性自体は妥当です。baseline_vc_preflight.py 由来の unexpected_pass / unsafe_command / command_not_allowed を reviewer_claim_replay.py の taxonomy に接続し、reviewer blocker を deterministic evidence で裁定したい、という狙いは Step 2a の設計と整合します。#1368 は open で、Issue コメントは現時点で 0 件です。

    ただし、現Issue契約のまま実装すると「局所テストだけ green」「full suite では fail」「直接 baseline_vc_preflight/v1 artifact 経路では未対応」「unsafe_command / command_not_allowed は実オーケストレーション上 human_judgment に落ち得る」という不一致が残ります。

    P0-1: Allowed Paths と AC5 が矛盾している

    #1368 は taxonomy に3エントリを追加し、AC5で「既存テスト全件 PASS」を要求していますが、Allowed Paths は reviewer_claim_replay.py と test_reviewer_claim_replay.py だけです。ところが既存の test_reviewer_claim_replay_taxonomy_parity.py は entry_id 集合を 4件に固定しており、unexpected_pass / unsafe_command / command_not_allowed を追加した瞬間に drift 検出で落ちます。

    これは偶然ではなく、Issue #1286 / PR #1304 系の設計で「taxonomy parity / dump drift を検出する」ために作られたテストです。--dump-taxonomy の出力と live constant が一致することも固定されています。

    修正要求: Allowed Paths に .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py を追加し、AC5 の Verification Command も少なくとも以下に変更してください。

    uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
    uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -v

    P0-2: --vc-preflight-result-file 経路が新カテゴリに対応しない

    Step 2a の documented invocation は --vc-preflight-result-file <baseline_vc_preflight_v1_path> を受け取れる契約です。

    しかし現行 reviewer_claim_replay.py の _matching_vc_preflight() は kind != "vc_command_format" の場合に即 [] を返します。つまり、taxonomy に3エントリを足しても、直接渡された baseline_vc_preflight/v1.results[] の unexpected_pass / unsafe_command / command_not_allowed は backing evidence として使われません。

    既存テストも直接 vc_preflight_result で backing するケースは C4 / compound_command_disallowed だけです。#1368 の AC2〜AC4 は「readiness 結果」を使う形なので、この直接 artifact 経路の穴を検出できません。

    修正要求: Issue本文のIn Scopeに、_matching_vc_preflight() の一般化を明示してください。最小方針は次です。

    def _matching_vc_preflight(kind, vc_preflight_result):
        if vc_preflight_result is None:
            return []
        results = vc_preflight_result.get("results", [])
        if not isinstance(results, list):
            raise ValueError("vc-preflight-result-file.results must be a list")
        entry = TAXONOMY_BY_ENTRY_ID.get(kind)
        categories = frozenset(entry["readiness_categories"]) if entry else frozenset()
        return [
            item for item in results
            if isinstance(item, dict) and item.get("category") in categories
        ]

    そのうえで、AC2〜AC4 は readiness 経路だけでなく、直接 vc_preflight_result 経路でも deterministic_fail_confirmed になることを要求してください。

    P0-3: unsafe_command / command_not_allowed は producer 側で needs_fix にならない可能性が高い

    baseline_vc_preflight.py は denylist command を blocked / unsafe_command に分類し、allowlist外コマンドを blocked / command_not_allowed に分類します。これは shell / network / filesystem mutation を遮断する静的安全設計として妥当です。

    外部仕様・実装慣行の観点でも、この方向は正しいです。Python subprocess.run() は shell=False を既定とし、引数列を渡す方法が quoting / escaping 管理上望ましいと説明しています。OWASP も OS command injection 対策として、OS command を直接呼ばないこと、避けられない場合は parameterization と command/argument の allowlist validation を使うことを推奨しています。([Python documentation]1) ([OWASP Cheat Sheet Series]2)

    問題は contract_readiness_check.py 側です。_PREFLIGHT_CATEGORY_TO_READINESS には unexpected_pass -> needs_fix はありますが、unsafe_command と command_not_allowed は見当たりません。未登録の blocked category は human_judgment に倒れる実装です。

    したがって、#1368 のゴールである「needs-fix ループが不要な human_escalation に倒れないようにする」は、reviewer_claim_replay.py の taxonomy 追加だけでは達成できません。ユニットテストで fabricated readiness payload を渡せば AC3/AC4 は通せますが、実 producer 経路では human_judgment として扱われ、Step 2a の前段で止まる可能性があります。

    修正要求: どちらかに絞ってください。

    1. 狭い修正: 実装: reviewer_claim_replay.py の taxonomy に unexpected_pass を追加する #1368 は unexpected_pass のみを対象にする。unsafe_command / command_not_allowed は別Issueで producer routing policy から設計する。
    2. 広い修正: Allowed Paths に contract_readiness_check.py とそのテストを追加し、unsafe_command / command_not_allowed を body-author-fixable needs_fix にするかどうかを明示的に決める。

    後者を選ぶ場合でも、安全ポリシーは緩めるべきではありません。修正対象は「危険コマンドを許可すること」ではなく、「危険/非allowlist VCを書いた Issue 本文を body-author に修正させる routing」です。

    P1-1: AC2〜AC4 が source spoofing に弱い

    #1368 の AC は「category: "unsafe_command" を含む readiness 結果」としか言っていません。現行 _matching_readiness_errors() は taxonomy entry 側の readiness_category_source_check が None なら category だけで一致します。

    これは category 文字列の衝突に弱いです。今回の3カテゴリは明確に baseline_vc_preflight 由来なので、entry は以下のように source を固定すべきです。

    readiness_rule_ids: []
    readiness_rule_id_source_check: null
    readiness_categories:
      - unexpected_pass
    readiness_category_source_check: baseline_vc_preflight
    domain_keys:
      - vc_unexpected_pass

    unsafe_command と command_not_allowed も同様に、readiness_category_source_check: baseline_vc_preflight を固定し、テストでは result["blockers"][0]["evidence"][0]["source_check"] == "baseline_vc_preflight" まで見るべきです。

    P1-2: AC1 の rg -c "unexpected_pass" は検証として弱い

    AC1 の Verification Command は単なる文字列出現数です。コメント、fix_hint、テスト名、既存 fixtures に文字列が出ても通ります。#1286 由来の設計は --dump-taxonomy と parity test で drift を検出する方向なので、AC1 も taxonomy JSON の構造を検証すべきです。

    推奨は pytest 側で dump_taxonomy() を直接検査することです。CLIでやるなら --dump-taxonomy を jq で検査してください。

    uv run --locked python3 .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py --dump-taxonomy \
      | jq -e '
          .schema == "REVIEWER_CHECKER_TAXONOMY_V1"
          and ([.entries[].entry_id] | index("unexpected_pass"))
          and ([.entries[].entry_id] | index("unsafe_command"))
          and ([.entries[].entry_id] | index("command_not_allowed"))
        '

    P1-3: SKILL.md の exact mapping は今回も stale になる

    #1368 は Required Design Reference として Step 2a を挙げていますが、現行 Step 2a の exact mapping は vc_command_format / ac_vc_number_mismatch / missing_section / rva_immediate_field_missing の4件だけです。出力契約も legacy 値中心で、taxonomy拡張と完全には同期していません。

    #1368 の Allowed Paths には SKILL.md が入っていないため、実装Issueとしては「doc更新は別Issue」として許容できます。ただし、その場合は Issue 本文に「Step 2a mapping doc の追従は Out of Scope / follow-up」と明記すべきです。現状の書き方だと Required Design Reference を参照しながら、その文書と実装の mapping drift を増やします。

    推奨する修正版スコープ

    最小で通すなら、#1368 を次のように書き換えるのが安全です。

    Allowed Paths:
      - .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
      - .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py
      - .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py

    Acceptance Criteria は以下に変更。

    AC1: --dump-taxonomy / dump_taxonomy() に unexpected_pass, unsafe_command, command_not_allowed の3 entry が存在し、
         各 entry は readiness_category_source_check == "baseline_vc_preflight" を持つ。
    
    AC2: readiness_result.errors[] に source_check == "baseline_vc_preflight", category == "unexpected_pass" を持つ artifact を渡すと、
         reviewer_blocker_code == "unexpected_pass" が deterministic_fail_confirmed になる。
    
    AC3: 同じ条件で unsafe_command が deterministic_fail_confirmed になる。
    
    AC4: 同じ条件で command_not_allowed が deterministic_fail_confirmed になる。
    
    AC5: 直接 baseline_vc_preflight/v1.results[] を --vc-preflight-result-file として渡した場合も、
         上記3カテゴリが deterministic evidence として使われる。
    
    AC6: test_reviewer_claim_replay.py と test_reviewer_claim_replay_taxonomy_parity.py が PASS する。
    

    unsafe_command / command_not_allowed を end-to-end の needs-fix loop に乗せたいなら、別途 contract_readiness_check.py の category mapping を変更するスコープを追加してください。そこまでやらない場合、#1368 のゴール文から「needs-fix ループが不要な human_escalation に倒れない」を削り、「Step 2a が当該 category を deterministic evidence として認識できる」に狭めるべきです。

  2. squne121 commented on Jul 7, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-07T22:05:18Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1368
      body_sha256: "sha256:9edc4de36b38d575a444824f67547d5c393bbcd1da21a5b955b90ff0a8e25268"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  3. changed the title [-]実装: reviewer_claim_replay.py の taxonomy に unexpected_pass/unsafe_command/command_not_allowed を追加する[/-] [+]実装: reviewer_claim_replay.py の taxonomy に unexpected_pass を追加する[/+] on Jul 7, 2026
  4. squne121 commented on Jul 7, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-07-08T00:00:00Z)

    • PR: fix: add unexpected_pass reviewer replay support (#1368) #1394
    • Worktree: .claude/worktrees/issue-1368-reviewer-claim-replay-py-taxonomy-unexpe
    • Branch: worktree-issue-1368-reviewer-claim-replay-py-taxonomy-unexpe
    • Verification:
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v PASS
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -v PASS
    • 後続: PR レビュー → マージ → post-merge-cleanup
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

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions