Skip to content

実装: adjudicate_vc_result.py の current PASS 認証を regression-gate 以外の VC 種別へ拡張する - #1497

Merged
squne121 merged 3 commits into
mainfrom
worktree-issue-1488-adjudicate-vc-result-py-current-pass-reg
Jul 13, 2026
Merged

squne121 merged 3 commits into
mainfrom
worktree-issue-1488-adjudicate-vc-result-py-current-pass-reg

Conversation

@squne121

@squne121 squne121 commented Jul 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • baseline_vc_preflight.py の classify_result() に evidence_mode パラメータを追加し、current-head モードで regression-gate 以外の VC(rg, test -f/test -s 等)が静的ポリシー通過かつ exit 0 の場合、expected_pass/go(category: expected_pass_resolved_on_current_head)として分類するように拡張しました。baseline モードのセマンティクスは変更していません。
  • adjudicate_vc_result.py 自体は変更していません(既に exit_code==0 かつ envelope status=="pass" でゲートしており、producer 側の本修正のみで要件を満たすことをコードリーディングで確認済み)。
  • [Update 2026-07-13] REQUEST_CHANGES fix_delta: reviewer 指摘(Blocker 1/2, Major 1/2)に対応し、current PASS への昇格を certify_current_pass_command() による target-scope 証明付き closed allowlist へ限定しました(詳細は下記「REQUEST_CHANGES fix_delta 対応」参照)。
  • Closes 実装: adjudicate_vc_result.py の current PASS 認証を regression-gate 以外の VC 種別へ拡張する #1488

Checks

  • AC1〜AC4は .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_current_head_non_regression.py を実行し、29件のテストすべてが成功した(fix_delta で実 subprocess ベースのテストへ書き換え、Blocker 1/2 反例テストを追加)。
  • AC5は .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result_non_regression_gate.py -k real_producer を実行し、3件のテストすべてが成功した。同ファイルには fix_delta で追加した E2E パイプラインテスト(実 baseline commit → 実 baseline producer → 実装 commit → 実 current-head producer → 実 git diff → adjudicator)と負例テスト(外部path・quiet部分エラー・HEAD drift)4件も含め、全7件が成功した。
  • AC6は .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py を実行し、139件が成功、1件は既存の無関係なスキップだった。
  • AC7は .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py を実行し、25件のテストすべてが成功した。
  • 上記4ファイルを合算実行しても200 passed, 1 skipped(相互汚染なし)。
  • ruff check PASS(変更3ファイル)。

再レビュー指摘への修正対応

前回 APPROVE 後に、より踏み込んだセキュリティ/正確性観点の REQUEST_CHANGES を受けました(対象コミット: head 9465a28、指摘コメント: #1497 (comment) )。修正後の最新コミットは 59937d3 です。以下に対応しました。

Blocker 1: current PASS の根拠が reviewed commit へ束縛されていない

指摘: exit_code == 0 と evidence_mode == "current-head" and static_policy_passed の2条件だけで expected_pass/go を返しており、allowed_paths に対する入力パス検査や stdout/stderr の完全性検査を行っていなかった。test -f /tmp/vc-sentinel のような repo 外の一時ファイル・環境状態だけで current PASS へ昇格しうる反例が再現された。

対応: certify_current_pass_command() を新設し、current PASS へ昇格可能なコマンドを closed allowlist(test -f|-d|-s <PATH> の完全一致 argv、rg PATTERN <PATH...>)に限定。全 path operand を _normalize_repo_relative_path_strict() で正規化した上で Allowed Paths 内であることを検証し、実行時点で実ファイルとして存在することも確認する。絶対パス・..・backslash・空 segment は拒否。grep/egrep/fgrep は path parser 未実装のため昇格対象から除外し、baseline と同じ unexpected_pass/blocked のままとした。producer 結果に certified_target_paths(検証済み target path のリスト)を追加した。

Blocker 2: rg -q / grep -q はエラー発生時でも exit 0 になりうる

指摘: quiet モードは一致さえ見つかれば、他 operand の missing-path/permission エラーがあっても exit 0 を返す。既存コードは stderr 内の "timeout" 文字列しか見ておらず、quiet search の部分成功+I/Oエラーをモデル化できていなかった。

対応: certify_current_pass_command() は stderr が非空なら無条件で fail-closed にする。実際に rg -q needle missing.txt match.txt(本番環境の ripgrep 14.1.0)を実行して再現確認したところ、exit 0 かつ stderr="rg: missing.txt: No such file or directory (os error 2)" となることを確認し、この quiet partial success を締め出すテストを追加した(rg -q: missing path + matching path、rg -q: unreadable path + matching path(実際に chmod 000 した実ファイルで再現)、grep -q: missing path + matching path、quiet search over directory containing unreadable entries、grep -s によるエラーメッセージ抑止、いずれも実 subprocess 実行で確認)。

Major 1: static_policy_passed のデフォルトが fail-open(True)

対応: static_policy_passed のデフォルトを False に変更した。既存の唯一の実 call site(main loop)は静的検査後に明示的に evidence_mode=args.evidence_mode とともに呼び出しており、デフォルト変更による既存挙動への影響はない(既存テストは全て static_policy_passed=True を明示していたことを確認済み)。デフォルトが安全側に倒れることを検証するテストを追加した。

Major 2: 新 category が confidence: low になる矛盾

対応: expected_pass_resolved_on_current_head を compute_confidence() の high 集合へ追加した。check_c13_vc_preflight_decision_consistency() に、このcategory が classification: expected_pass / decision: go / confidence: high の組み合わせと一致することを検証するクロスフィールド一貫性チェックを追加し、それぞれのテスト(整合ケースの pass、confidence:low の reject、classification 不一致の reject)を追加した。CLI E2E テストで実際の producer 出力が confidence: "high" と certified_target_paths を含むことも確認した。

テスト設計の修正

  • 既存の AC1〜AC4 テストを、手入力の stdout/stderr に依存する形から、実際に rg/test/grep を subprocess 実行して得た実 exit_code/stdout/stderr を使う形へ全面的に書き換えた。
  • test_adjudicate_vc_result_non_regression_gate.py に、reviewer 指摘の「本当に同じ VC が baseline expected-fail から current-pass へ遷移したか」を証明する完全な E2E フィクスチャを追加した: (1) 実 baseline commit 作成、(2) 実 baseline producer 実行・snapshot 保存、(3) 別 commit で Allowed Paths 内を変更、(4) 実 current-head producer 実行、(5) 実 git diff から diff summary 生成、(6) adjudicator へ渡す。
  • 同ファイルに負例(外部path、quiet部分エラー(削除+一致)、HEAD drift)も E2E パイプラインで追加した。

Schema Change Applicability

  • decision: schema_change
    baseline_vc_preflight.py の producer envelope に、新しい追加的(additive)な category 値 expected_pass_resolved_on_current_head を追加したため schema_change として扱います。既存の category 値(fail、environment_blocked 系、vc_no_tests_collected 等)の意味や出力条件は変更していません。あくまで current-head モードでのみ到達する新分類を1つ追加しただけであり、既存 category の producer 側セマンティクスは後方互換です。
    [fix_delta 追加] producer 結果アイテムに新規フィールド certified_target_paths(category が expected_pass_resolved_on_current_head の場合のみ非 null、それ以外は null)を追加しました。これも additive change です。

Schema Consumer Inventory

# Before
producer envelope の category 値集合(consumer である adjudicate_vc_result.py が判定に使う範囲):
  - ENVIRONMENT_BLOCKED_CATEGORIES に属する各 category 値
  - "vc_no_tests_collected"(完全一致判定)
  - その他の category 値(上記いずれにも該当しない場合は素通り)

# After
  - 上記の値集合に "expected_pass_resolved_on_current_head" を追加
  - ENVIRONMENT_BLOCKED_CATEGORIES にも vc_no_tests_collected にも該当しないため、
    adjudicate_vc_result.py 側の判定ロジックは変更なしで新 category を正しく扱える
  - certified_target_paths フィールドは adjudicate_vc_result.py のどの判定ロジックからも
    参照されない(_normalize_item() は ac / command_hash / exit_code / category /
    failure_keys / classification のみを読む)ため、consumer 側の変更は不要
Consumer ファイル 更新有無 備考
.claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py 更新不要 category を ENVIRONMENT_BLOCKED_CATEGORIES 所属判定と vc_no_tests_collected 完全一致判定にのみ使用しており、新 category expected_pass_resolved_on_current_head はどちらにも該当しないため後方互換。certified_target_paths フィールドも _normalize_item() が読む固定キー集合に含まれないため無視される。既存の exit_code==0 かつ envelope status=="pass" によるゲートのみで新 category を含む envelope を正しく扱える。コードリーディングと AC5 の real-producer boundary test(test_adjudicate_vc_result_non_regression_gate.py -k real_producer、3件PASS)、および fix_delta で追加した E2E パイプラインテスト(4件PASS)の両方で確認済み。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
classify_result() の新分岐は current-head モードで regression-gate 以外の VC が exit 0 かつ静的ポリシー通過時のみ expected_pass/go に分類し、既存の unsafe/broad-search/invalid-regex/malformed-test/timeout/regression-gate 判定の昇格を防ぐ yes None 新分岐は既存の unsafe/broad-search/invalid-regex/malformed-test/timeout/regression-gate 判定がすべて return した後にのみ到達する構造をコードリーディングで確認済み。テスト: .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_current_head_non_regression.py(29件PASS)。 -
current PASS への昇格は certify_current_pass_command() の closed allowlist(test -f / test -d / test -s / rg)に限定され、path operand が repo-relative かつ Allowed Paths 内・実ファイルとして存在することを要求し、repo 外の一時ファイル・環境状態だけでは昇格しない yes None Blocker 1 反例テスト(test_blocker1_test_f_on_repo_external_tmp_path_is_never_certified 等)、E2E 負例テスト(test_e2e_negative_repo_external_path_never_resolves_via_pipeline)で確認済み。grep/egrep/fgrep は path parser 未実装のため closed allowlist から除外し baseline と同じ unexpected_pass/blocked を維持(Issue #1488 本文の元々の Out of Scope 範囲内、新たな未制御ギャップではない)。 None
rg -q/grep -q の quiet partial success(一致操作対象は成功、別 operand は missing-path/permission エラー)は stderr 非空により fail-closed で拒否される yes None 実 ripgrep 14.1.0 / grep で再現した Blocker 2 反例テスト(test_blocker2_rg_quiet_missing_path_plus_matching_path_never_certified 等5件)、E2E 負例テスト(test_e2e_negative_quiet_partial_error_delete_and_match_never_resolves)で確認済み。 -
static_policy_passed はデフォルト False(fail-closed)であり、呼び出し側が静的検査を忘れても current PASS へ誤昇格しない yes None test_ac4_static_policy_passed_defaults_to_false_fail_closed で signature default を直接検証。 -
expected_pass_resolved_on_current_head は常に confidence: high かつ classification/decision と一貫する yes None test_major2_expected_pass_resolved_on_current_head_is_high_confidence、test_major2_schema_consistency_* 3件、CLI E2E テストで実 producer 出力を確認。 -
adjudicate_vc_result.py は新 category を ENVIRONMENT_BLOCKED_CATEGORIES 判定・vc_no_tests_collected 完全一致判定のいずれにも該当させず、後方互換のまま既存ゲートで動作する yes None コードリーディングで確認、AC5 の real-producer boundary test(.claude/skills/impl-review-loop/tests/test_adjudicate_vc_result_non_regression_gate.py -k real_producer、3件PASS)と fix_delta E2E テスト(4件PASS)で実挙動を確認済み。 -

Notes

衝突ゲートの明示的バイパスについて

open-pr skill の open_pr.py overlap hard gate(Issue #1458)は、machine route が human_review_required の場合 PR 作成を fail-closed でブロックします。今回 check_implementation_overlap.py は #944 / #961 / #962 / #966 / #1053 / #1338 / #1396 との構造的衝突検出(多くは broad Allowed Paths 宣言由来の false positive)により human_review_required を返しました。

各候補の ## Outcome / ## In Scope を実際に readback し、全候補が本 Issue #1488 のスコープと disjoint であることを確認済みです(証跡: https://github.com/squne121/loop-protocol/issues/1488#issuecomment-4959195723)。

この readback 証跡に基づき、人間の明示的承認により、今回の Issue #1488 に限り overlap hard gate をバイパスし、gh pr create を直接実行してこの PR を作成しました(open_pr.py 経由ではありません)。恒久的な waiver 機構の拡張や候補 Issue のスコープ整理は別途 follow-up として検討予定です。

テスト計画

  • AC1–AC7 検証コマンドを実行し全て PASS を確認した(fix_delta 後も再確認済み、200 passed, 1 skipped の合算実行含む)
  • レビュー(pr-review-judge)を実施した(1回目 REQUEST_CHANGES: Safety Claim Matrix / Schema Change Applicability / Schema Consumer Inventory セクション欠落 → 対応済み。2回目 APPROVE 後、3回目 REQUEST_CHANGES: current PASS 認証ロジックのセキュリティ/正確性指摘(Blocker 1/2, Major 1/2)→ 本 fix_delta で対応)。

…rtified PASS化 (#1488)

Issue #1453 / PR #1460 が実装した producer-certified current PASS 認証
(expected_fail_resolved_on_current_head)は regression-gate 種別
(pnpm typecheck/lint/test/build、実在パス pytest)にしか適用されなかった。

baseline_vc_preflight.py の classify_result() に evidence_mode パラメータを
追加し、current-head evidence-mode で静的 policy を通過して実行された
非 regression-gate VC(rg / test -f / test -s 等)の exit 0 を
expected_pass / go(category: expected_pass_resolved_on_current_head)として
分類するようにした。baseline evidence-mode の既存意味論
(unexpected_pass / blocked)は変更していない。

adjudicate_vc_result.py 本体(producer envelope scheme・consumer 側判定
ロジック)は変更していない。producer 側の修正のみで完結する(Issue の
Out of Scope 参照)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1497/

The preview will be removed when this PR is closed.

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-review-judge 判定への対応(LOOP_VERDICT_V2: REQUEST_CHANGES)

reviewed_head_sha: 9465a28d6a8955dc8336d194a797a09a6010cc23(現在の head と一致、race なし)に対する REQUEST_CHANGES を受け、required_auto_actions(kind: update_pr_body_hygiene, mechanical: true)に従い PR 本文を更新しました。コード変更は行っていません(head SHA は変更なし)。

Blocker 対応

  • Safety Claim Matrix 欠落: .claude/skills/** 配下の変更(safety-sensitive)に対する Safety Claim Matrix セクションを追加しました。reviewer 所見どおり、classify_result() の新分岐は既存の unsafe/broad-search/invalid-regex/malformed-test/timeout/regression-gate 判定がすべて return した後にのみ到達する構造であり、current PASS の誤昇格を防ぐことをテスト(test_baseline_vc_preflight_current_head_non_regression.py、14件PASS)とともに明記しました。
  • Schema Change Applicability / Schema Consumer Inventory 欠落: producer envelope に追加的(additive)な category 値 expected_pass_resolved_on_current_head が加わったことを明示し、decision: schema_change を宣言しました。consumer である adjudicate_vc_result.py は category を ENVIRONMENT_BLOCKED_CATEGORIES 所属判定と vc_no_tests_collected 完全一致判定にのみ使用しており、新 category はどちらにも該当しないため後方互換で consumer 側の変更は不要である旨を Consumer Inventory テーブルに記載しました。

検証

  • validate_pr_body.py を対象3ファイル(Allowed Paths どおり)と linked-issue #1488 で実行し status: pass を確認しました。
  • validate_japanese_content.py --threshold 0.1 を実行し aggregate_ratio: 0.525, failed_blocks: 0, PASS を確認しました。
  • 本文更新は open-pr/scripts/update_pr.py wrapper 経由で実行し、gh pr edit 直接呼び出しは行っていません。

コード側の変更は無いため、AC1〜AC7 の再検証・再push は不要です。

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR レビュー結果(LOOP_VERDICT_V2)

再レビューにより、前回のブロッカー(PR本文の Safety Claim Matrix / Schema Change Applicability セクション欠落)が解消されたことを確認しました。

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "9465a28d6a8955dc8336d194a797a09a6010cc23"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  blockers: []
  required_auto_actions: []
  follow_up_issue_requests:
    - description: "ci_verdict_summary.py の exclude rule に HEAD_SHA_NULL_SKIPPED パターンを追加し、pull_request_review 再トリガー時の Check Japanese Content skip 重複計上を解消する"
      blocking_merge_ready: false
  allowed_paths_gate:
    status: ok
    changed_files:
      - .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result_non_regression_gate.py
      - .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
      - .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_current_head_non_regression.py
    violations: []
  producer_role: review_subagent
  worker_report_used_as_canonical: false

確認事項

  • PR本文の REQUIRED_SECTIONS(Summary/Checks/Schema Change Applicability/Schema Consumer Inventory/Safety Claim Matrix/Notes)全て存在、placeholder なし。Closes #1488 あり。
  • Allowed Paths: 変更3ファイルが Issue #1488 の Allowed Paths と完全一致(git diff --name-status -M -z main...FETCH_HEAD で独立確認)。
  • コード: classify_result() の新分岐は既存の unsafe/broad/invalid-regex/malformed/timeout/regression-gate 判定がすべて return した後にのみ到達する構造であることを diff で確認済み。test_adjudicate_vc_result_non_regression_gate.py は実サブプロセスによる境界テストであることを確認済み。
  • CI: 現 head_sha で typecheck/lint/build/test/e2e/python-test/actionlint/ci-verdict-summary 全て SUCCESS。

@squne121

Copy link
Copy Markdown
Owner Author

判定:REQUEST_CHANGES

PR #1497 は draft・mergeable で、変更は3ファイル、実装本体の差分は小さく、CIも typecheck / lint / test / build / E2E / Python suite を含めて成功しています。

しかし、reviewed commitと無関係な外部状態や、検索中にエラーが発生した不完全な成功を certified current PASS として承認できる経路があります。CI greenでもマージ不可です。


Blocker 1:current PASSの根拠がreviewed commitへ束縛されていない

新分岐は、非regression-gateコマンドについて次の2条件しか見ません。

exit_code == 0
evidence_mode == "current-head" and static_policy_passed

これだけで expected_pass / go を返します。allowed_paths、コマンドの入力パス、stdout・stderrの完全性は確認していません。

ところが、静的ポリシーで許可されるコマンドには test、grep、fgrep、egrep などが含まれます。
Allowed Pathsとの包含検査は rg 専用で、コードコメントでも grep / egrep / fgrep are NOT in scope と明記されています。

--strict も一般的なスコープ検査ではありません。対象が「新しいAllowed Path」で、かつ baseline-expect がない場合だけブロックします。

再現可能な反例

## Allowed Paths
- src/feature.ts

Verification Commands

# AC1
# baseline-expect: fail
$ test -f /tmp/vc-sentinel
</code></pre><pre><code>
1. baseline実行時は `/tmp/vc-sentinel` が存在せず、exit 1 → `expected_fail / go`
2. 実装では `src/feature.ts` だけを変更
3. current-head実行前に、別プロセスが `/tmp/vc-sentinel` を作成
4. `test -f` はexit 0
5. PRの新分岐が `expected_pass / go` を返す
6. HEADとworktreeは正常・cleanなのでproducer envelopeはpass
7. adjudicatorは、変更パスがAllowed Paths内で、current itemがexit 0ならpassにする

GNU Coreutilsの `test -f` は、対象が通常ファイルとして存在すれば真になります。:contentReference[oaicite:7]{index=7}

adjudicator側はcurrent PASSについてコマンドの入力パスを再検証せず、認証済みenvelope・exit 0・failure keyなしだけでpassを確定します。 

**つまり、リポジトリ外の一時ファイルや環境状態だけでACを解決できます。** worktree clean、HEAD一致、body hash一致ではこの問題を検出できません。

### 必須修正

current PASSへ昇格可能なコマンドをclosed allowlist化してください。

- `test` は `test -f|-d|-s &lt;PATH&gt;` の完全一致argvだけ許可
- `&lt;PATH&gt;` は正規化済みrepo-relative pathかつAllowed Paths内であること
- 絶対パス、`..`、backslash、空segmentを拒否
- `rg` / `grep` は全path operandについて同じ包含検査を行う
- `grep`系はpath parserが実装されるまでcurrent PASS昇格対象外にする
- producer結果に、検証済みtarget pathまたはtarget-scope digestを含める

---

## Blocker 2:`rg -q` / `grep -q` はエラーが発生してもexit 0になり得る

ripgrepの公式manpageでは、通常はエラー時exit 2ですが、`-q/--quiet` で一致が見つかった場合は例外的にexit 0になると明記されています。読み取り不能ファイルなどのsoft errorも対象です。

GNU grepも同様で、`-q` 使用時に一致行があれば、別のエラーが発生していてもexit 0になります。さらに `-s` はエラーメッセージ自体を抑止します。:contentReference[oaicite:11]{index=11}

今回のコードは、stderr内の文字列 `"timeout"` だけを先に確認し、それ以外はexit 0だけでcurrent PASSへ昇格します。rgのmissing-pathやpermission errorの詳細判定へ到達する前です。

### 実際に再現した結果

```text
$ rg -q needle missing.txt match.txt
exit_code=0
stderr=rg: missing.txt: No such file or directory (os error 2)
</code></pre><p>以下の遷移でfalse greenになります。</p><ul><li><p>baseline:</p><ul><li><p><code inline="">deleted.txt</code> と <code inline="">changed.txt</code> が両方存在</p></li><li><p>どちらにも <code inline="">needle</code> がない</p></li><li><p><code inline="">rg -q needle deleted.txt changed.txt</code> → exit 1 → expected fail</p></li></ul></li><li><p>current head:</p><ul><li><p><code inline="">deleted.txt</code> を削除</p></li><li><p><code inline="">changed.txt</code> に <code inline="">needle</code> を追加</p></li><li><p>両方ともAllowed Paths内の変更</p></li><li><p>同じコマンド → <strong>missing-file errorを伴うexit 0</strong></p></li><li><p>producerがexpected pass</p></li><li><p>adjudicatorがAC解決としてpass</p></li></ul></li></ul><p>追加テストもこの問題を捉えていません。単体テストでは <code inline="">rg -q</code> に対し、手入力した <code inline="">stdout="match found\n"</code> と空stderrを渡しており、quiet searchの部分成功+I/Oエラーをモデル化していません。</p><h3>必須修正</h3><p>exit 0を直接認証根拠にせず、コマンド別の「完全成功」判定を導入すべきです。</p><pre><code class="language-python">certify_current_pass(
    command,
    exit_code,
    stdout,
    stderr,
    cwd,
    allowed_paths,
) -&gt; CertificationResult
</code></pre><p>少なくとも検索コマンドでは次を要求してください。</p><ul><li><p>全path operandがrepo-relativeかつAllowed Paths内</p></li><li><p>quietモードで複数pathまたはdirectory検索を認証しない</p></li><li><p>stderrが非空ならfail-closed</p></li><li><p>エラー抑止オプションをcurrent PASS認証では拒否</p></li><li><p>可能ならripgrep configの環境依存を無効化</p></li><li><p>missing/readability状態を実行前後に検証</p></li></ul><p>追加すべき負例:</p><pre><code class="language-text">rg -q: missing path + matching path
rg -q: unreadable path + matching path
grep -q: missing path + matching path
quiet search over directory containing unreadable entries
error-message suppression enabled
</code></pre><hr><h2>Major 1:安全性フラグがfail-open defaultになっている</h2><p><code inline="">static_policy_passed</code> のデフォルト値が <code inline="">True</code> です。したがって、別のcall siteが次のように静的ポリシー実行を忘れてもcurrent PASSになります。</p><pre><code class="language-python">classify_result(
    exit_code=0,
    stdout="",
    stderr="",
    command="...",
    evidence_mode="current-head",
)
</code></pre><p>関数docstring自身が、この値をcurrent PASSの認証条件として使用しています。</p><p>現在のmain call siteは静的検査後に明示的に <code inline="">True</code> を渡していますが、安全境界のデフォルトとしては逆です。</p><h3>修正</h3><ul><li><p>最低限 <code inline="">static_policy_passed=False</code></p></li><li><p>よりよい設計はbooleanを廃止し、静的検証から返された改ざんしにくいproof objectを渡す</p></li><li><p>さらに良いのは、<code inline="">classify_result()</code> を汎用分類器のまま維持し、current-head昇格をorchestrator側の専用関数へ分離する</p></li></ul><hr><h2>Major 2:新しい「certified PASS」が <code inline="">confidence: low</code> になる</h2><p>新categoryの <code inline="">expected_pass_resolved_on_current_head</code> が <code inline="">compute_confidence()</code> のhigh/medium集合へ追加されていません。未知categoryは自動的にlowになります。</p><p>各resultは必ずcategoryからconfidenceを生成するため、今回追加されたcertified PASSは実際には次のような矛盾した出力になります。</p><pre><code class="language-json">{
  "classification": "expected_pass",
  "category": "expected_pass_resolved_on_current_head",
  "decision": "go",
  "confidence": "low"
}
</code></pre><p>PR本文はcategory追加をschema changeとして扱っていますが、この派生フィールドへの影響がConsumer Inventoryとテストから漏れています。</p><h3>修正</h3><ul><li><p>categoryを適切なconfidence集合へ追加</p></li><li><p>current-head JSON全体をassertするテストを追加</p></li><li><p><code inline="">classification / category / decision / scope_class / confidence</code> の組合せをschema consistency checkに追加</p></li></ul><hr><h2>テスト設計の修正方針</h2><p>現在のreal-producer boundary testは、current producerは実行していますが、baseline snapshotとdiff summaryは手書きです。したがって、<strong>本当に同じVCがbaseline expected-failからcurrent passへ遷移したか</strong>までは証明していません。</p><p>次のE2E fixtureが必要です。</p><ol><li><p>baseline commitを作成</p></li><li><p>baseline producerを実行して実際のsnapshotを保存</p></li><li><p>別commitでAllowed Paths内を変更</p></li><li><p>current-head producerを実行</p></li><li><p>実際のgit diffからdiff summaryを生成</p></li><li><p>adjudicatorへ渡す</p></li><li><p>外部path、quiet partial error、HEAD drift、削除+一致の各負例を確認</p></li></ol><hr><h2>最終評価</h2>
項目 | 判定
-- | --
CI | PASS
baseline互換性 | 概ね維持
current-head source integrity | 不十分
command target scope | 未認証
quiet search error handling | false greenあり
schema派生フィールド | 更新漏れ
マージ可否 | 不可

<p>実装方針自体は妥当ですが、現状は「静的ポリシー通過+exit 0」を「reviewed commitによる完全なAC解決」と同一視しています。この抽象化が強すぎます。<strong>command-specific completeness proofとtarget-scope proofを追加してから再レビュー</strong>が必要です。</p></body></html><!--EndFragment-->
</body>
</html>

PR #1497 の REQUEST_CHANGES(reviewed_head_sha: 9465a28)対応。

## Blocker 1: current PASS の根拠が reviewed commit へ束縛されていない

`exit_code == 0` だけを根拠に current PASS へ昇格していたため、Allowed
Paths 外・リポジトリ外の一時ファイル(例: /tmp/vc-sentinel)に対する
`test -f` でも certified current PASS になり得た。

`certify_current_pass_command()` を新設し、current PASS へ昇格可能な
コマンドを `test -f|-d|-s <PATH>`(完全一致 argv)と `rg PATTERN
<PATH...>` のみの closed allowlist にした。全 path operand を
strict repo-relative 正規化した上で Allowed Paths 内であることを検証し、
実行時点で実ファイルとして存在することも確認する。`grep`/`egrep`/`fgrep`
は path parser 未実装のため昇格対象から除外(baseline と同じ
unexpected_pass/blocked のまま)。producer 結果には
`certified_target_paths` を追加。

## Blocker 2: `rg -q` / `grep -q` はエラー発生時でも exit 0 になりうる

quiet mode は一致さえあれば他 operand の missing-path/permission エラー
があっても exit 0 を返す(実測で再現確認済み)。`certify_current_pass_
command()` は stderr が非空なら無条件で fail-closed にし、この quiet
partial success を締め出す。

## Major 1: static_policy_passed のデフォルトが fail-open

`static_policy_passed` のデフォルトを `True` から `False` に変更。

## Major 2: 新 category が confidence: low になる矛盾

`expected_pass_resolved_on_current_head` を `compute_confidence()` の
high 集合へ追加し、`check_c13_vc_preflight_decision_consistency()` に
classification/decision/confidence の一貫性チェックを追加した。

## テスト

- 既存テストを実 subprocess ベース(rg/test/grep の実実行)へ書き換え、
  手入力 stdout/stderr への依存を排除。
- Blocker 1/2 の反例(repo外パス、Allowed Paths外、grep系、quiet部分
  エラー、権限エラー、ディレクトリ検索、エラー抑止フラグ)を追加。
- 実 baseline commit → 実 baseline producer → 実装 commit → 実
  current-head producer → 実 git diff → adjudicator という完全な E2E
  パイプラインテストを追加し、外部path/quiet部分エラー/HEAD drift の
  負例も含めた。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 再レビュー結果(LOOP_VERDICT_V2)

外部レビューで指摘された Blocker 1/2・Major 1/2・テスト設計不備への修正対応を、pr-reviewer が diff と実行結果に基づき独立検証し、全て解消済みと確認しました。

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "59937d30e5f33b4ebd0524c09df93429bf808154"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  blockers: []
  required_auto_actions: []
  allowed_paths_gate:
    status: ok
    changed_files_count: 3
    violations: []
  producer_role: review_subagent
  worker_report_used_as_canonical: false

独立検証結果

  1. Blocker 1(reviewed commitへの束縛不足): 解消。certify_current_pass_command() の closed allowlist(test -f|-d|-s <PATH> 完全一致 / rg PATTERN <PATH...> のみ、grep系除外)と _normalize_repo_relative_path_strict() による Allowed Paths 包含検査・実在性検査を確認した。
  2. Blocker 2(quiet mode 部分成功): 解消。stderr 非空なら fail-closed。実 ripgrep/grep subprocess による5パターンの再現テストが全て成功した。
  3. Major 1(fail-open default): 解消。static_policy_passed のデフォルトが False に変更され、唯一の call site は明示的に True を渡している。
  4. Major 2(confidence矛盾): 解消。新 category を compute_confidence() の high-confidence 集合に追加し、cross-field consistency check も追加した。
  5. テスト設計: 解消。実 baseline から current-head への完全 E2E パイプラインテストと3負例(外部path・quiet部分エラー・HEAD drift)を追加した。

残存事項(non-blocking、follow-up候補)

_certified_path_exists_as_file() が symlink を追跡する点は今回スコープ外(既存 Issue #1328 のパターンを踏襲)である。follow-up の要否は人間判断に委ねる。

実行確認コマンド

  • test_baseline_vc_preflight_current_head_non_regression.py: 29件成功
  • test_adjudicate_vc_result_non_regression_gate.py: 7件成功
  • test_baseline_vc_preflight.py と test_adjudicate_vc_result.py の合算: 164件成功、1件スキップ
  • ruff check: 全て問題なし
  • ci_verdict_summary.py --expected-head-sha 59937d30...: all_pass

@squne121
squne121 marked this pull request as ready for review July 13, 2026 21:47
@squne121
squne121 merged commit 3ad166c into main Jul 13, 2026
26 checks passed
@squne121
squne121 deleted the worktree-issue-1488-adjudicate-vc-result-py-current-pass-reg branch July 13, 2026 21:47
squne121 added a commit that referenced this pull request Jul 13, 2026
…行を両立させる

baseline_vc_preflight.py で、main 側 (#1497: adjudicate_vc_result.py の current PASS 認証を
regression-gate 以外の VC 種別へ拡張) が追加した classify_result() への evidence_mode 引数と
result item の certified_target_paths フィールドが、本ブランチ (#1338: 同一 command の
dedup/replay と bounded parallel execution) が導入した deferred job batch 実行フェーズでは
未反映のまま欠落する競合だったため、以下の方針で解消した。

- 2 箇所のコンフリクトは HEAD 側 (#1338 の pending_jobs/継続処理と batch dedup 実行フェーズ)
  を正として採用し、旧来の即時 classify_result 呼び出し・inline result dict 構築 (origin/main
  側、#1497 の変更を含む) は _build_result_item() ヘルパーへの統合によって既に重複しているため
  破棄した
- _build_result_item() に certified_target_paths パラメータとフィールドを追加し、即時実行
  パス・batch 実行パスの両方の呼び出し箇所に certified_target_paths 算出ロジックを追加した
- batch 実行フェーズの classify_result() 呼び出しに evidence_mode=args.evidence_mode を追加し、
  current-head モードでの証跡拡張が dedup/並列実行パス経由でも機能するようにした

検証: test_baseline_vc_preflight_current_head_non_regression.py (29 pass, CLI 経由の
certified_target_paths アサーションを含む)、test_baseline_vc_preflight.py (139 pass, 1 skip)、
test_baseline_vc_preflight_dedup.py / _parallel.py / _default_seconds.py / _pnpm_no_tty.py
(43 pass)、test_adjudicate_vc_result_non_regression_gate.py (7 pass)、Issue #1338 全 AC の
Verification Commands (dedup/parallel/wrapper_wiring, 計 18 pass) を実行し全 PASS を確認した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

実装: adjudicate_vc_result.py の current PASS 認証を regression-gate 以外の VC 種別へ拡張する

1 participant