Skip to content

feat(#201): add trivially_pass detection for --paths forced include in baseline_vc_preflight - #583

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-201-trivially-pass-detection
Jun 2, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-201-trivially-pass-detection

Conversation

@squne121

@squne121 squne121 commented Jun 2, 2026 •

Copy link
Copy Markdown
Owner

概要

issue-contract-review の VC preflight に trivially_pass カテゴリを追加し、VC が形骸化(trivially-pass)する構造を静的に検出して decision: blocked を返せるようにした。

検出対象は repository-local の discovery スクリプト(match-ssot.sh / match_ssot.py および ssot-discovery/scripts/ 配下)を --keywords と --paths の両方を指定して呼び出すパターンである。これらのスクリプトは --paths の directory mapping により、--keywords が baseline に存在しなくても対象 path を結果へ強制的に含めてしまうため、VC が常に成功し検証として機能しない。

rg / grep には --paths という forced-include オプションは存在しないため、当初の rg / grep を対象とする実装は誤りであった。本 PR では検出対象を discovery スクリプトへ修正し、--paths を検索語として扱う正当な VC を誤検出しないようにした。

変更内容

  • baseline_vc_preflight.py: _is_trivially_pass_command() を discovery スクリプト + --keywords + --paths 併用検出へ再設計した。判定順序を denied-command 検出より前へ移動し、bash でラップした呼び出しでも trivially_pass として分類されるようにした。
  • SKILL.md: Step 4 のカテゴリ表と Step 5 のガイドラインを、正しい検出対象(discovery スクリプトの --keywords + --paths 併用)の説明へ更新した。
  • docs/dev/dor.md: 「trivially-pass 禁止」の説明を正しい構造の説明へ更新した。
  • テストを discovery スクリプトの回帰ケースと false-positive ガードへ置き換えた。

検証結果

標準ゲートと pytest はすべて成功している。実行結果は以下のとおり。

pnpm typecheck : pass
pnpm lint      : pass
pnpm test      : 313/313 pass (16 files)
pnpm build     : pass
uv run pytest test_vc_format_and_command_policy.py : 63/63 pass

受け入れ条件(AC1〜AC5)の baseline から実装後への遷移は以下のとおり。

AC1 rg trivially_pass baseline_vc_preflight.py : exit1 -> exit0
AC2 rg trivially_pass SKILL.md                 : exit1 -> exit0
AC3 rg forced_include / --paths SKILL.md       : exit1 -> exit0
AC4 rg trivially_pass docs/dev/dor.md          : exit1 -> exit0
AC5 pnpm lint                                  : pass  -> pass

OWNER レビュー(#issuecomment-4601752505)で指摘された挙動を再確認した。結果は以下のとおりで、すべて期待どおりである。

bash match-ssot.sh --keywords X --paths Y : category=trivially_pass / decision=blocked
rg -e "--paths" file                      : trivially_pass ではない(false positive 解消)
rg -- "--paths" file                      : trivially_pass ではない
match-ssot.sh で --keywords のみ          : trivially_pass ではない

変更ファイル

変更したファイルはすべて拡張後の Allowed Paths の範囲内である。

.claude/skills/issue-contract-review/SKILL.md
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
.claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py
docs/dev/dor.md

安全性の主張整理(Safety Claim Matrix)

変更パスが .claude/skills/issue-contract-review/**(safety-sensitive path)に該当するため、安全性に関わる主張の有無を明示する。本変更はいずれの項目についても新たな safety claim を導入しない。

安全性の観点 変更の有無 備考
権限昇格 なし preflight classifier への静的検出カテゴリ追加のみで、権限モデルは変更しない
sandbox 緩和 なし sandbox 境界には影響しない
認証の取り扱い なし auth フローは変更しない
secret の取り扱い なし secret の読み書きやログ出力は変更しない
ネットワーク境界 なし ネットワークアクセスのパターンは変更しない

本変更は VC の形骸化パターンを検出して GO 判定を厳格化するものであり、安全性を強化する方向の変更である。

本 PR のマージで Issue をクローズする。Closes #201

🤖 Claude Code で生成

…n baseline_vc_preflight

Add `trivially_pass` category to `baseline_vc_preflight.py` to detect search commands
(rg/grep family) that use `--paths <target>` to force-include the target in results,
making the VC structurally trivially-passing regardless of implementation state.

- `_is_trivially_pass_command()`: detects `--paths` / `--paths=<val>` in rg/grep argv
- `classify_static_command()` step 11: returns `category: trivially_pass` / `decision: blocked` (static, pre-execution)
- `compute_confidence()`: trivially_pass added to `high_confidence` set
- SKILL.md Step 4: added `trivially_pass` row to category table and step 0.f in logic
- SKILL.md Step 5: added `--paths` forced include guideline section
- `docs/dev/dor.md`: added `trivially-pass 禁止` subsection under VC baseline 差分性ルール
- tests: 5 new test cases covering trivially_pass detection (60 total, all pass)

Co-Authored-By: Claude Sonnet 4.6 <[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.

Verdict: REQUEST_CHANGES

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=BEHIND
  • BEHIND は Conflict blocker / Merge blocker に非該当。APPROVE 時は recommendations: [update_branch] を付与する予定だった。

Evidence Check

  • AC coverage: 全 AC に対応する実装が diff で確認済み
    • AC1: _is_trivially_pass_command() 関数 + classify_static_command() check 11 で --paths 強制 include を静的検出し category: trivially_pass / decision: blocked を返す実装あり(テキスト追記のみでない)
    • AC2: SKILL.md Step 4 カテゴリテーブル行追加 + Step 0.f 分類ロジック参照追記あり
    • AC3: SKILL.md Step 5 に --paths 強制 include ガイドライン追記あり
    • AC4: docs/dev/dor.md に trivially-pass 禁止サブセクション追記あり
    • AC5: CI lint job pass(head SHA 一致確認済み)
  • Allowed Paths 遵守: 変更 4 ファイルすべてが最新 contract snapshot(#issuecomment-4601647042)の拡張後 Allowed Paths 内
  • CI Verification: CI run 26814774869(headSha=f162a60f455c3ae40371d4d5fb065cde5039db0e)全 job(build/e2e/lint/python-test/test/typecheck/validate-generated-artifact)conclusion=success。CI_CHECK_RUN_SCOPED 条件(head_sha 一致・conclusion=success)を満たす。TEST_VERDICT_MACHINE コメントは存在しないが CI_CHECK_RUN_SCOPED 証跡で補完。
  • false positive 確認: test_rg_without_paths_is_not_trivially_pass が --paths なし rg を trivially_pass に分類しないことを確認しており、正規 VC の誤 block はない。
  • scope 混入: なし。変更は #201 スコープ(trivially_pass 検出)に限定されている。

Blockers

  1. Safety Claim Matrix 欠落(APPROVE 禁止)

    • 変更 path .claude/skills/issue-contract-review/SKILL.md / .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py / .claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py は SKILL.md Step 4.6 の safety-sensitive 判定条件 changed path matches .claude/skills/** に該当する。
    • PR 本文に ## Safety Claim Matrix セクションが存在しない。
    • SKILL.md Step 4.6: 「safety-sensitive と判定された PR は、PR 本文に Safety Claim Matrix セクションが存在することを確認する」「safety-sensitive PR なのに Safety Claim Matrix セクションが存在しない → APPROVE 禁止」

    修正方法: PR 本文に ## Safety Claim Matrix セクションを追加してください。本 PR の変更(VC preflight に静的検出カテゴリを追加)は新たな安全主張を導入するものではないため、## Schema Change Applicability: not_schema_change 相当の記述(safety-sensitive path に該当するが safety claim を変更しない理由を明示)か、最小限の Safety Claim Matrix(Claim 列に「なし」を明記)で対応可能です。

Non-blockers

  1. forced_include_trivially_pass カテゴリ名について: AC1 に forced_include_trivially_pass カテゴリが言及されているが、実装では trivially_pass のみ使用されている。contract の forced_include_trivially_pass は実装では trivially_pass に統合された形になっており、compute_confidence の high_confidence セットも trivially_pass のみ。TEST_VERDICT が 60 pass で通過していることから機能的に問題ないが、contract と実装のカテゴリ名の齟齬をコメントに記録する(non-blocker)。

LOOP_VERDICT

verdict: REQUEST_CHANGES
blockers:
  - Safety Claim Matrix セクションが PR 本文に存在しない(SKILL.md Step 4.6 safety-sensitive path .claude/skills/** 該当)
mergeable: MERGEABLE
mergeStateStatus: BEHIND
reviewed_head_sha: f162a60f455c3ae40371d4d5fb065cde5039db0e
recommendations: []
follow_up_issue_requests: []

@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.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=BEHIND

Evidence Check

  • AC coverage: AC1-5 全て PR 本文の Verification Commands 結果テーブルに baseline/post-impl 比較で記載済み
  • Allowed Paths: 4ファイル全て .claude/skills/issue-contract-review/** / docs/dev/dor.md - Allowed Paths 内
  • CI Verification: CI run 26814774869 / head_sha=f162a60f455c3ae40371d4d5fb065cde5039db0e - build/e2e/lint/python-test/test/typecheck 全 pass(CI_CHECK_RUN_SCOPED 条件を満たす)
  • 検証コマンド結果: AC1-5 の rg コマンド + pnpm typecheck/lint/test/build + uv run pytest (313/313 pass, 60/60 pass) が本文に記録済み
  • Safety Claim Matrix: ## Safety Claim Matrix セクション存在確認。5つの safety dimension (権限昇格/sandbox緩和/auth/secret/ネットワーク) が全て「なし」と明示。PR title に overclaim キーワードなし。Not controlled に相当する次元が全て空(「なし」)のため APPROVE 禁止条件 (2)-(4) 非該当。変更の性質(GO 判定厳格化・safety 強化方向)明記あり。

Blockers

  • なし

Non-blockers

  • mergeStateStatus=BEHIND のため merge 前に update-branch 推奨

LOOP_VERDICT

verdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: BEHIND
reviewed_head_sha: f162a60f455c3ae40371d4d5fb065cde5039db0e
recommendations: [update_branch]
follow_up_issue_requests: []

@squne121

squne121 commented Jun 2, 2026

Copy link
Copy Markdown
Owner Author

結論: REQUEST_CHANGES / マージ不可

PR #583 は CI 上は成功しており、Draft PR として 2 commits・4 files changed・7 checks の状態です。直近の Actions run も success です。([GitHub]1) ([GitHub]2)
ただし、実装の中核が 元 Issue の失敗モードと別物を検出しているため、このままマージすると「trivially-pass を検出できるようになった」という過大な安全感だけが残ります。


Blocker 1: 元 Issue の原因は rg/grep --paths ではなく、match-ssot.sh --keywords ... --paths ...

Issue #201 の背景で示されている問題コマンドは、bash .claude/skills/ssot-discovery/scripts/match-ssot.sh --keywords ... --paths ... です。--paths が directory mapping により target path を返し、keyword が実装前に存在しなくても PASS しうる、というのが根本原因です。([GitHub]3)

ところが PR の実装は _is_trivially_pass_command() で argv[0] の basename を rg, grep, fgrep, egrep に限定しています。つまり、元の match-ssot.sh / match_ssot.py 系の trivially-pass は検出対象外です。([GitHub]4)

これは AC1 の「--paths <target> 引数が検索結果に target を強制 include する構造を検出したら blocked」という目的に対して、実装対象を誤っています。Issue #201 の In Scope / AC は baseline_vc_preflight.py に trivially_pass カテゴリを追加し、--paths 強制 include を検出することを要求しています。([GitHub]3) ([GitHub]3)


Blocker 2: rg / grep の --paths という技術前提が不正確

ripgrep の公式 manpage では検索対象 path は positional PATH であり、path の include/exclude は -g/--glob などで扱います。--paths という forced-include option は確認できません。([Debian Manpages]5) ([Debian Manpages]5)
GNU grep も基本形は grep [OPTION]... PATTERNS [FILE]... で、--paths という option は公式 manual 上確認できません。([GNU]6) ([GNU]6)

そのため、PR が追加した説明「rg / grep 系コマンドが --paths <target> を使い検索対象 target を強制 include する」は、一般的な rg / grep の仕様説明として誤りです。PR 本文・SKILL.md・DoR がこの誤仕様を前提にしており、今後の agent に無効な VC パターンを学習させます。([GitHub]7) ([GitHub]4) ([GitHub]4)


Blocker 3: valid な rg VC を誤 block する false positive がある

実装は argv の全引数を走査し、arg == "--paths" または arg.startswith("--paths=") なら即 trivially_pass にしています。([GitHub]4)
しかし ripgrep は dash で始まる pattern を検索する場合、-e/--regexp や -- delimiter を使えます。([Debian Manpages]5)

そのため、例えば次のような正当な VC も誤 block されます。

rg -n -e "--paths" .claude/skills/issue-contract-review/SKILL.md
rg -n -- "--paths" docs/dev/dor.md

これは「--paths という文字列が docs に存在すること」を検証する普通の検索であり、forced include ではありません。今回の PR は rg --path-separator など近接 option との混同は避けていますが、-e / -- 後の pattern 位置を解釈していないため、検索語としての --paths を壊します。([Debian Manpages]5)


Blocker 4: テストが人工的で、実際の失敗事象を再現していない

追加テストは rg ... --paths ...、grep ... --paths ...、rg --paths=... を中心にしています。([GitHub]4)
しかし元 Issue の発火例は match-ssot.sh --keywords ... --paths ... であり、現在の match_ssot.py は実際に --paths を argparse で受け取り、directory mapping から low relevance の matched_documents を生成する実装です。([GitHub]8)

したがって、最低限次の回帰テストがない限り、AC1 の実効性は証明できません。

def test_match_ssot_with_keywords_and_paths_is_trivially_pass_blocked():
    body = """## Verification Commands
```bash
# AC13
$ bash .claude/skills/ssot-discovery/scripts/match-ssot.sh --keywords "milestone,github-milestone" --paths "docs/dev/milestone-ops.md"

"""
data = run_preflight(body)
r = data["results"][0]
assert r["classification"] == "blocked"
assert r["category"] == "trivially_pass"
assert r["decision"] == "blocked"
assert r["exit_code"] is None


逆に、次の negative tests も必要です。

```python
def test_rg_literal_paths_pattern_is_not_trivially_pass():
    assert _is_trivially_pass_command('rg -n -e "--paths" docs/dev/dor.md') is False
    assert _is_trivially_pass_command('rg -n -- "--paths" docs/dev/dor.md') is False

修正方針

rg / grep を主対象にするのではなく、repository-local discovery scripts の --keywords + --paths 併用を静的に検出してください。特に match-ssot.sh / match_ssot.py / .claude/skills/ssot-discovery/scripts/ 配下を対象にするのが妥当です。PR #200 のレビューでも AC13 の --paths forced include が問題観察として明示されています。([GitHub]9)

分類順は、shlex parse と compound-command 検出の後、denylist / allowlist の前に置くべきです。実行はしないので safety relaxation ではありません。現状の順序では bash が先に unsafe_command になり、元 Issue の失敗モードが trivially_pass として識別されません。([GitHub]10)


Ready-to-post review comment

## Verdict: REQUEST_CHANGES

### Blockers

1. **Root cause mismatch**
   - Issue #201 の元失敗事象は `bash .claude/skills/ssot-discovery/scripts/match-ssot.sh --keywords ... --paths ...` であり、`rg` / `grep --paths` ではありません。
   - 現実の trivially-pass は ssot-discovery の `--paths` が directory mapping で target path を low relevance として返す構造です。
   - 現実装は `_is_trivially_pass_command()` を `rg|grep|fgrep|egrep` に限定しており、元の問題を検出できません。

2. **Invalid technical premise**
   - `rg` / `grep` に `--paths` forced-include option があるという説明は不正確です。
   - ripgrep の path 指定は positional `PATH`、include/exclude は `-g/--glob` 等です。
   - GNU grep も `grep [OPTION]... PATTERNS [FILE]...` であり、`--paths` option は確認できません。

3. **False positive**
   - `rg -n -e "--paths" docs/dev/dor.md`
   - `rg -n -- "--paths" docs/dev/dor.md`
   - これらは正当な literal search ですが、現実装では `arg == "--paths"` を見て `trivially_pass` に誤分類します。

4. **Test coverage does not reproduce the incident**
   - 追加テストは人工的な `rg/grep --paths` だけで、Issue #201 の実コマンド `match-ssot.sh --keywords ... --paths ...` を検証していません。

### Required fix

- `rg` / `grep --paths` 前提の説明・テストを撤回または大幅修正する。
- `match-ssot.sh` / `match_ssot.py` / `.claude/skills/ssot-discovery/scripts/` の `--keywords` + `--paths` 併用を `trivially_pass` / `blocked` として静的検出する。
- 検出は `shlex` parse と compound-command 検出の後、denylist / allowlist の前に置く。
- `rg -e "--paths"` および `rg -- "--paths"` が false positive にならない negative test を追加する。

現状では CI は pass していますが、AC1 の実効性が満たされていないため merge 不可です。

この PR は「安全ゲートを厳格化する方向」自体は妥当ですが、今の差分は検出対象を外しているため、修正してから再レビューが必要です。

…pt --keywords+--paths

Root cause of Issue #201 was that match-ssot.sh's directory mapping forces
--paths targets into matched_documents regardless of keyword presence. The
previous implementation incorrectly targeted rg/grep + --paths (rg has no
--paths option) causing false positives for 'rg -e "--paths" file' queries,
and could not detect 'bash match-ssot.sh ...' which was blocked at step 4
(denied-command) before reaching step 11 (trivially_pass).

Changes:
- _is_trivially_pass_command(): detect discovery script (match-ssot.sh /
  match_ssot.py / ssot-discovery/scripts/*) called with BOTH --keywords AND
  --paths; removes the incorrect rg/grep --paths logic
- classify_static_command(): move trivially_pass check to step 3.5, before
  denied-command check (step 4), so 'bash match-ssot.sh --keywords ... --paths ...'
  gets category: trivially_pass instead of category: unsafe_command
- Tests: replace rg/grep --paths tests with discovery script regression tests;
  add false-positive guard for 'rg -e "--paths"' / 'rg -- "--paths"'
- SKILL.md Step 4/5 + dor.md: retract incorrect rg/grep --paths premise;
  replace with correct discovery script --keywords+--paths description

Co-Authored-By: Claude Sonnet 4.6 <[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.

レビュー結果: APPROVE(承認)

マージ可能性確認

mergeable=MERGEABLE, mergeStateStatus=CLEAN。コンフリクトなし。

エビデンス確認結果

AC カバレッジは5/5すべてPASSを確認した。AC1(baseline_vc_preflight.py に trivially_pass カテゴリが lines 542/847 で実装済み)、AC2(SKILL.md Step 4 の trivially_pass テーブルに記載済み)、AC3(SKILL.md Step 5 に --paths 強制 include ガイドラインが記載済み)、AC4(dor.md に trivially-pass 禁止が明記済み)、AC5(pnpm lint が CI で pass)— すべて git show origin/worktree-issue-201-trivially-pass-detection で独立確認済み。

変更4ファイル(.claude/skills/issue-contract-review/SKILL.md, scripts/baseline_vc_preflight.py, tests/test_vc_format_and_command_policy.py, docs/dev/dor.md)はすべて Issue #201 Allowed Paths 内に収まっており Allowed Paths 遵守を確認した。

CI 証跡として typecheck/lint/test/build/e2e/python-test/validate-generated-artifact すべて pass を確認した。CI run 26816013255(ci workflow)および 26816422586(Check Japanese Content workflow)ともに head_sha=f6614b7091cd59f44a3949f4dc0c593a91eb7fd9 で conclusion=success であり、CI_CHECK_RUN_SCOPED 条件(head_sha 一致・conclusion=success・VC 対応)を満たす。

検証コマンド結果: AC1〜5 すべて baseline(exit1/fail)→実装後(exit0/pass) の遷移が PR 本文に記録済み。OWNER 指摘4件の再確認結果(bash match-ssot.sh --keywords X --paths Y → trivially_pass/blocked、rg/rg-- の false positive なし)も記録済み。

前回ブロッカー4件の解消確認(イテレーション2)

  1. Root cause mismatch 解消: 検出対象が rg/grep(存在しない --paths オプション)から discovery スクリプト(match-ssot.sh/match_ssot.py)の --keywords+--paths 併用に正しく再設計された。
  2. Invalid premise 解消: rg/grep に --paths という forced-include オプションが存在するという誤前提を docstring・SKILL.md・dor.md から撤回し、正しい説明に置き換えた。
  3. False positive 解消: rg -e "--paths" file / rg -- "--paths" file が trivially_pass として誤分類されないことを負例テストで確認した。
  4. Tests don't reproduce incident 解消: 旧 rg/grep テストを削除し、discovery スクリプトの回帰テストと false-positive ガードテストを追加。pytest 63 passed(CI python-test: pass で確認)。

Safety Claim Gate 確認

変更パスに .claude/skills/ 配下が含まれるため safety-sensitive と判定した。PR 本文に「安全性の主張整理(Safety Claim Matrix)」セクションが存在し、全5項目すべて「変更の有無: なし」で新たな安全性主張は導入されていない。Not controlled 列に該当なく overclaim なし。本変更は VC 形骸化パターンの検出強化であり安全性を高める方向の変更である。PASS。

ブロッカー

なし

Non-blockers(任意改善)

なし

LOOP_VERDICT

verdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: f6614b7091cd59f44a3949f4dc0c593a91eb7fd9
recommendations: []
follow_up_issue_requests: []

@squne121
squne121 marked this pull request as ready for review June 2, 2026 11:39
@squne121
squne121 merged commit 7b4f914 into main Jun 2, 2026
18 of 19 checks passed
@squne121
squne121 deleted the worktree-issue-201-trivially-pass-detection branch June 2, 2026 11:39
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.

実装: issue-contract-review の VC preflight に trivially-pass パターン検出を追加する

1 participant