Skip to content

fix: add unexpected_pass reviewer replay support (#1368) - #1394

Merged
squne121 merged 5 commits into
mainfrom
worktree-issue-1368-reviewer-claim-replay-py-taxonomy-unexpe
Jul 8, 2026
Merged

squne121 merged 5 commits into
mainfrom
worktree-issue-1368-reviewer-claim-replay-py-taxonomy-unexpe

Conversation

@squne121

@squne121 squne121 commented Jul 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • reviewer_claim_replay.py で direct --vc-preflight-result-file を deterministic backing に使う前に、source.body_sha256 と review/readiness の body hash を fail-closed に照合するようにしています。
  • direct preflight matching は real producer semantics に寄せ、artifact 全体では status == "blocked"、unexpected_pass では classification == "unexpected_pass"・category == "unexpected_pass"・decision == "blocked" を要求するようにしています。
  • preflight evidence は producer shape の line を line_start == line_end == line に正規化し、command_hash・raw_command・classification・decision などの metadata も保持します。
  • 回帰テストは producer shape の fixture に更新し、stale body hash、missing body hash、category-only spoof、line 正規化を固定しています。

Checks

受け入れ条件の達成状況

  • AC1: vc_preflight_result.source.body_sha256 が review/readiness body hash と一致しない場合は input_or_runtime_error で fail-closed し、deterministic evidence に採用しないことを追加テストで固定しました。
  • AC2: direct preflight fixture を baseline_vc_preflight.py の producer shape に寄せ、source.body_sha256、status、results[].ac/line/raw_command/command_hash/classification/category/decision/scope_class/confidence を含む形へ更新しました。
  • AC3: direct unexpected_pass matching で classification == "unexpected_pass"、category == "unexpected_pass"、decision == "blocked" を要求し、spoof artifact が backing にならないことを確認しました。
  • AC4: stale body hash、missing body hash、malformed category-only spoof、line 正規化の回帰テストを追加しました。
  • AC5: 指定の pytest 2 本を再実行し、両方 PASS を確認しました。

検証コマンド結果

  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py -v
    • PASS(38件、全件成功)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay_taxonomy_parity.py -v
    • PASS(21件、全件成功)

CI fix delta(2026-07-08)

  • python-test の Ruff E501 指摘に合わせ、.claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py の raw_command fixture 文字列だけを折り返しました。
  • 挙動変更はなく、long line / formatting のみを修正しています。
  • uv run --locked ruff check .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py --select E501
    • PASS

Allowed Paths 遵守

Notes

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1394 closed).

@squne121

squne121 commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

判定: REQUEST_CHANGES

PR #1394 は、Issue #1368 の修正後スコープには概ね沿っています。unexpected_pass の taxonomy entry 追加、readiness_category_source_check == "baseline_vc_preflight" の固定、_matching_vc_preflight() の vc_command_format 限定解除、readiness 経路・direct preflight 経路・dump-taxonomy parity test 追加までは妥当です。PR は draft/open、変更は3ファイル・75行追加/2行削除で、PR上の実質コメントは preview URL を貼る bot コメントのみです。

ただし、direct --vc-preflight-result-file 経路が stale artifact を deterministic evidence として採用できるため、このまま merge は危険です。

Blocker: vc_preflight_result.source.body_sha256 を照合していない

Issue #1368 は、readiness 経路だけでなく --vc-preflight-result-file に results[].category == "unexpected_pass" を含む場合も deterministic_fail_confirmed にすることを要求しています。 そのため、このPRで direct baseline artifact 経路を一般化したこと自体は正しいです。実装も unexpected_pass entry に readiness_categories: ["unexpected_pass"] と readiness_category_source_check: "baseline_vc_preflight" を追加しています。

問題は、reviewer_claim_replay.py が review/readiness の body_sha256 は fail-closed に照合する一方、vc_preflight_result 側の source.body_sha256 を一切見ていない点です。analyze() は review/readiness hash の存在と一致だけを確認します。 一方、baseline_vc_preflight.py の実出力には source.body_sha256 が含まれます。 しかし _matching_vc_preflight() は results[] の category だけで一致判定し、artifact 全体の hash を無視します。 さらに _evidence() は preflight artifact 自身の body hash ではなく、呼び出し側から渡された readiness/review hash を evidence に刻印します。

このため、次のような stale pairing が成立します。

review_result["body_sha256"] = "sha256:new"
readiness_result["body_sha256"] = "sha256:new"

vc_preflight_result = {
    "schema": "baseline_vc_preflight/v1",
    "source": {"body_sha256": "sha256:old"},
    "results": [{"category": "unexpected_pass"}],
}

現実には sha256:old の preflight evidence なのに、現在のコードは sha256:new の deterministic evidence として扱い、deterministic_fail_confirmed に進み得ます。これは Step 2a の「同一 body に対する deterministic arbitration」という前提を壊します。PR #1304 で review/readiness の stale artifact pairing を fail-closed にした設計とも整合しません。

修正要求:

vc_preflight_result を deterministic backing として使う前に、少なくとも以下を満たしてください。

source = vc_preflight_result.get("source", {})
vc_body_sha256 = source.get("body_sha256") if isinstance(source, dict) else None
if vc_body_sha256 != body_sha256:
    raise ValueError("vc-preflight-result-file source.body_sha256 mismatch")

既存互換を重視するなら「missing は deterministic evidence として採用しない」でもよいですが、--vc-preflight-result-file を明示入力として使うなら fail-closed が妥当です。

追加テストは最低限この2本です。

def test_unexpected_pass_vc_preflight_requires_matching_source_body_sha256():
    ...

def test_unexpected_pass_vc_preflight_body_sha_mismatch_is_input_error_not_confirmed():
    ...

High: direct preflight fixture が producer shape ではない

追加テストの direct preflight fixture は results[].line_start / line_end を持っています。 しかし baseline_vc_preflight.py の実 producer は line, raw_command, command_hash, classification, category, decision, scope_class, confidence, stdout/stderr head などを出します。

つまり、テストは「実 producer artifact」ではなく reviewer_claim_replay 側に都合のよい人工 shape で通っています。現実の direct preflight artifact を渡すと _evidence() は line_start / line_end を拾えず、evidence の行番号が None になります。deterministic 判定そのものは通るかもしれませんが、reviewer replay の evidence としては劣化します。

修正要求:

direct preflight test は producer shape に寄せてください。

preflight = {
    "schema": "baseline_vc_preflight/v1",
    "source": {"kind": "body_file", "body_sha256": "sha256:body-a"},
    "status": "blocked",
    "results": [
        {
            "ac": "AC2",
            "line": 12,
            "raw_command": "rg ...",
            "command_hash": "sha256:...",
            "classification": "unexpected_pass",
            "category": "unexpected_pass",
            "decision": "blocked",
            "scope_class": "baseline_fail_expected",
            "confidence": "high",
        }
    ],
    "errors": [],
}

そのうえで _evidence() か preflight evidence builder 側で、line を line_start == line_end == line に正規化してください。

High: category だけで direct preflight evidence とみなすのは緩すぎる

現在の _matching_vc_preflight() は item.get("category") in categories だけを見ます。 しかし real producer では unexpected_pass は classification == "unexpected_pass" かつ category == "unexpected_pass" かつ decision == "blocked" です。

direct file input は外部 artifact なので、category-only matching は spoofing に弱いです。例えば {"classification": "expected_fail", "category": "unexpected_pass", "decision": "go"} のような壊れた artifact でも backing になります。

修正要求:

unexpected_pass については最低限、以下を条件に入れてください。

item.get("classification") == "unexpected_pass"
item.get("category") == "unexpected_pass"
item.get("decision") == "blocked"

vc_command_format など blocked 系カテゴリについても、direct preflight result を採用するなら decision == "blocked" を見るべきです。readiness 経路は contract_readiness_check.py が baseline_vc_preflight を readiness error に写像しており、source_check と category が揃うので現在の設計で妥当です。direct artifact 経路だけは producer semantics を追加確認してください。

Medium: 実装技術の方向性は正しいが、今回のPRはその安全境界にただ乗りしている

baseline_vc_preflight.py の基本設計は、shlex.split() で argv を作り、subprocess.run(..., shell=False) で実行し、denylist/allowlist で危険コマンドを抑止する構造です。 これは Python 公式ドキュメントが推奨する「引数列で渡す」「shell を暗黙に使わない」方向、および OWASP の「OS command を避ける、避けられない場合は parameterization と allowlist validation を使う」方針と整合します。([Python documentation]1)

ただし、このPRの direct artifact 経路は、せっかく producer が持っている source.body_sha256、classification、decision、command_hash を reviewer replay 側で十分に検証・保持していません。安全な producer を使っていても、consumer が stale/malformed artifact を受け入れると arbitration が崩れます。

問題なしと判断した点

unsafe_command / command_not_allowed を今回実装しない判断は妥当です。Issue #1368 はこれらを producer routing 変更が必要な別Issue扱いにし、本Issueを unexpected_pass のみに限定しています。 contract_readiness_check.py も現状 unexpected_pass -> needs_fix は持っていますが、unsafe_command / command_not_allowed は同じ mapping に入っていないため、今回巻き込まないほうが安全です。

taxonomy parity の更新も方向性は正しいです。Issue #1286 / PR #1304 系の設計では、REVIEWER_CHECKER_TAXONOMY_V1 と --dump-taxonomy の drift をテストで検出することが目的です。 今回の parity test は entry set に unexpected_pass を追加し、readiness_category_source_check == "baseline_vc_preflight" まで固定しています。

Merge 条件

このPRは、次を満たすまで merge しないほうがよいです。

  1. vc_preflight_result.source.body_sha256 を review/readiness body hash と照合する。
  2. direct preflight fixture を real producer shape に寄せる。
  3. unexpected_pass direct matching で classification == "unexpected_pass" と decision == "blocked" を要求する。
  4. stale body hash、malformed category-only spoof、real line 正規化の回帰テストを追加する。
  5. 既存の2コマンドに加え、追加テスト込みで以下を再実行する。
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

現状のPR本文にある PASS は自己申告として確認しましたが、このレビューではローカル実行までは行っていません。

squne121 commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

判定: APPROVE

  • reviewed_head_sha: 8bdcb25dea0b166bd58465cdd23c34c31803f4b4
  • 前回 blocker だった vc_preflight_result.source.body_sha256 未照合は、analyze() 内の fail-closed 検証追加と mismatch/missing 回帰テスト追加で解消を確認しました。
  • direct preflight 経路は status == "blocked" / decision == "blocked" を前提にし、unexpected_pass では classification/category/decision の producer semantics まで照合する形に強化されています。
  • evidence は producer shape の line を line_start == line_end == line に正規化し、raw_command / command_hash / classification / decision なども保持するようになっています。
  • wait_ci_checks.sh --required の current-head 判定では typecheck, test, python-test, lint, build, validate-generated-artifact がすべて SUCCESS でした。
  • Allowed Paths は GitHub PR files oracle の 3 changed files を linked issue 実装: reviewer_claim_replay.py の taxonomy に unexpected_pass を追加する #1368 の Allowed Paths と照合し、すべて範囲内であることを確認しました。
  • 非blockingメモ: ci_verdict_summary.py では optional な PR Body Japanese Check failure が見えますが、required-only CI には含まれておらず merge-blocking ではありません。

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: "8bdcb25dea0b166bd58465cdd23c34c31803f4b4"
merge_ready: true
mergeability:
  mergeable: "MERGEABLE"
  merge_state_status: "UNSTABLE"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
  status: ok
  changed_files_source: github_pull_request_files_api_with_previous_filename
  changed_files:
    - .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
allowed_paths_gate_source: review_subagent

@squne121
squne121 marked this pull request as ready for review July 8, 2026 11:54
@squne121
squne121 merged commit 7de1f6d into main Jul 8, 2026
17 of 18 checks passed
@squne121
squne121 deleted the worktree-issue-1368-reviewer-claim-replay-py-taxonomy-unexpe branch July 8, 2026 11:54
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.

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

1 participant