Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "578"
change_kind: workflow
goal_ref: "Verification Command の regex alternation と shell pipe を区別し、非弁別 VC を事前検出する"Parent Issue
#578 (VC 用語の日本語標準化と textlint/prh 辞書登録)
Parent Goal Ref
- Goal: 実装: VC 用語の日本語標準化と textlint/prh 辞書登録を追加する #578 の impl-review-loop 中に露呈した VC 品質問題(shell pipe / regex alternation の誤判定)を修正する
- Desired Destination:
issue-contract-reviewの VC preflight が shell pipe と regex alternation を別レイヤーで正しく扱い、rg / grep -E の\|literal-pipe 誤用を非弁別 VC として検出できる状態
Current Validated Scope
issue-contract-reviewのcontract_readiness_check.py/baseline_vc_preflight.pyに regex-bearing command classifier とregex_literal_pipe_suspected判定を追加するcreate-issue/references/body-authoring.mdに literal-pipe annotation の構文を定義するtest-runner.mdに「VC 逐語実行・省略禁止」要件を追記する- 上記に対応するテストを追加する
Remaining Parent Gaps
なし(本 Issue 単独で完結)
Background
Issue #578 の impl-review-loop 中に、AC3 / AC4 の Verification Commands が | を \| に変換された結果、ripgrep では alternation ではなくリテラル pipe として解釈され、実装後も exit=1 になる非弁別 VC になっていた。
この問題は実装対象 PR の不備ではなく、issue-refinement-loop / issue-contract-review / test-runner 側の VC 生成・検証責務の不備である。
具体的欠陥:
- shell pipe 禁止ルールが、引用符内の regex alternation
|と shell pipelinecmd1 | cmd2を区別できていない rg -n "a\|b"のような pattern が意図した alternation ではなくリテラル pipe になることを検出できない- baseline preflight が exit=1 を「変更前状態では失敗すべき」とだけ扱い、実装後も成立しない非弁別 VC を見抜けない
- test-runner が Issue 記載の VC を逐語実行せず、パターンを簡略化して PASS と自己申告できてしまう
技術的根拠:
ripgrep は Rust regex engine を使用する。Rust regex では x|y は alternation。ASCII punctuation の escape は literal として扱われるため \| は literal pipe を意味する。したがって "foo|bar"(alternation)と "foo\|bar"(literal pipe 検索)は意味が異なる。
Outcome
実装完了後、以下の状態になる:
issue-contract-reviewの VC 解析が、regex-bearing command(rg / grep -E / egrep)の pattern 引数内|を shell pipeline operator と誤判定しない- regex-bearing command の pattern に
\|が含まれる場合、regex_literal_pipe_suspectedとして分類し、literal-pipe-ok annotation がない限りblockedと判定する create-issue/references/body-authoring.mdに literal-pipe annotation の正規構文が定義されているtest-runner.mdに VC 逐語実行・省略禁止の要件が明記されている- 上記を検証する pytest テストが PASS する
In Scope
-
.claude/skills/issue-contract-review/scripts/contract_readiness_check.py- regex-bearing command classifier を追加(対象:
rg,grep -E,egrep) - pattern 引数内の
|を shell operator と誤分類しない修正
- regex-bearing command classifier を追加(対象:
-
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py- regex-bearing command の pattern slot に
\|が含まれる場合のregex_literal_pipe_suspected分類 - literal-pipe-ok annotation がない場合は
blocked判定
- regex-bearing command の pattern slot に
-
.claude/skills/issue-contract-review/tests/test_vc_regex_pipe_semantics.py(新規)- AC1–AC3 / AC6 の fixture テスト
-
.claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py(追加または新規)- AC5 / AC7 のテスト
-
.claude/skills/create-issue/references/body-authoring.md- literal-pipe annotation の構文定義(
# vc-regex-intent: literal-pipe-ok reason="..."形式)
- literal-pipe annotation の構文定義(
-
.claude/agents/test-runner.md- VC 逐語実行・省略禁止の要件追記
-
.claude/skills/review-issue/**/.claude/agents/issue-reviewer.md(必要な場合のみ)- structured blocker の lossless pass-through 確認
-
.claude/skills/edit-issue/**/.claude/agents/issue-author.md(必要な場合のみ)- VC 修復時の literal-pipe 検出対応
Out of Scope
- Issue 実装: VC 用語の日本語標準化と textlint/prh 辞書登録を追加する #578 本体の再修正
.textlint/prh.ymlやdocs/dev/glossary.mdの用語定義変更- shell command 全体の完全な構文解析器の新規実装
- ripgrep 以外の regex engine(PCRE2 / Perl / grep BRE)の完全互換性検証
- Windows cmd.exe / PowerShell grammar の対応
.claude/skills/issue-refinement-loop/への判定ロジック追加(thin entrypoint 設計を維持する)- issue-refinement-loop からの作業コンテキスト削除・移行(別 Issue で扱う)
Acceptance Criteria
- AC1: quote 内の
rg -n "foo|bar"は VCS001 違反にならない(regex alternation として扱われる) - AC2: quote 外の
cmd1 | cmd2は従来どおり VCS001 違反として検出される(shell pipeline として扱われる) - AC3:
rg -n "foo\|bar"が VC に含まれる場合、regex_literal_pipe_suspectedとして分類され、literal-pipe-ok annotation がない限りblockedになる - AC4:
test-runner.mdに「Issue 記載 VC を逐語実行し、パターン削除・簡略化・置換を禁止する」旨が明記されている - AC5:
baseline_vc_preflight.pyが、regex-bearing command(rg / grep -E / egrep)の pattern に\|を検出した場合にregex_literal_pipe_suspectedを返し、annotation なしの場合decision: blockedを返すテストが PASS する - AC6: 実装: VC 用語の日本語標準化と textlint/prh 辞書登録を追加する #578 の AC3/AC4 と同型の fixture テスト(
rg -n "foo|bar"は pass、rg -n "foo\|bar"はregex_literal_pipe_suspected→ blocked)が存在し PASS する - AC7: 既存の VC validation / refinement / test-runner 関連テストが PASS する
Literal-Pipe Annotation Format
\| を regex-bearing command の pattern に使用する正当な理由がある場合(対象テキストにリテラルパイプが含まれる等)、VC の直前行に以下の annotation を付与することで blocked を回避できる:
# AC3
# vc-regex-intent: literal-pipe-ok reason="対象テキストにリテラルパイプが含まれるため"
$ rg -n "foo\|bar" docs/annotation の構文ルール:
- VC コマンドの直前行(コマンドと連続した行)に記述する
# vc-regex-intent: literal-pipe-ok reason="<理由>"の形式- コマンド末尾コメントではなく、直前行コメントに限定する
Verification Commands
AC 対応コマンド一覧:
# AC1 # AC2 # AC3 # AC6
$ uv run pytest .claude/skills/issue-contract-review/tests/test_vc_regex_pipe_semantics.py -v# AC4
$ rg -n "逐語実行|VC.*verbatim|verbatim.*VC" .claude/agents/test-runner.md# AC5 # AC7
$ uv run pytest .claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py -v# AC7 (regression)
$ uv run pytest .claude/skills/issue-contract-review/tests/ -v$ pnpm typecheck$ pnpm test$ pnpm buildAllowed Paths
変更対象ファイル(スコープ外の変更は Stop Condition):
.claude/skills/issue-contract-review/SKILL.md.claude/skills/issue-contract-review/scripts/contract_readiness_check.py.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py.claude/skills/issue-contract-review/tests/test_vc_regex_pipe_semantics.py.claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py.claude/skills/create-issue/references/body-authoring.md.claude/agents/issue-author.md.claude/skills/edit-issue/**.claude/skills/review-issue/**.claude/agents/issue-reviewer.md.claude/agents/test-runner.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- shell command の完全な構文解析器の実装が必要になった場合
- ripgrep 以外の regex engine 対応が必要になった場合
- Claude Code 本体の hook / tool 実装変更が必要と判明した場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Runtime Verification Applicability
ブラウザまたはゲームランタイムを必要とする動作検証は不要。
decision: not_applicable
reason: "VC 生成・静的検証・手順文書の改善であり、ブラウザまたはゲームランタイムを必要としない"
Activity
squne121 commentedon Jun 3, 2026
判定
REQUEST CHANGES / 実装着手前に Issue #589 自体を修正すべきです。
狙いは妥当です。#578/#587 で実際に
rgの正規表現|と\|の扱いがレビュー問題になっており、VC が「変更前FAILだからOK」と誤って通る弱点も確認できます。ただし、現在の #589 は contract / VC / metadata / scope が粗く、このまま実装 Issue として渡すと、また「検証できたことにする PR」を生みやすいです。参照した関連事項
#589 は
parent_issue: 578で、目的は「Verification Command の regex alternation|と shell pipe|を区別し、非弁別的 VC を検出する」ことです。背景には、#578 の AC3/AC4 で|が\|に変換され、ripgrepでは alternation ではなく literal pipe として解釈され、実装後も exit 1 になる非弁別 VC になった、という問題が書かれています。([GitHub]1)#578 は VC 用語の日本語標準化と textlint/prh 登録の実装 Issue で、#587 がそれを実装して merged 済みです。#587 のレビューでは
.textlintignoreの re-include 問題、glossary 内の旧用語が prh に壊される問題、regex の境界不足などが指摘され、最終的には修正コミット後に承認されています。([GitHub]2)また #201 は
issue-contract-reviewの VC preflight にtrivially_pass検出を追加する運用 Issue で、VC が見かけ上 PASS するだけで検証能力を持たない問題を扱っています。#589 はその派生ですが、対象は--pathsforced include ではなく、regex escaping / shell pipe / post-implementation satisfiability の欠落です。([GitHub]3)ブロッカー
1. Issue title と body が実装用 contract として不適切
#589 のタイトルは 「後で変えて1」 です。さらに本文末尾に
BODYEOFとgh issue create --title ... --body-file ...が残っています。これは明らかな here-doc / CLI 作業残骸で、machine-readable contract として扱うには危険です。([GitHub]1)修正すべきタイトルは、本文末尾に残っている意図から見て次が妥当です。
2. labels / branch / PR metadata が未整備
#589 は labels なし、assignee なし、project/milestone なし、development branch/PR なしです。少なくとも #578 と同じく
kind/implementation/phase/implementation相当の metadata は必要です。#578 はそのラベルが付いていました。([GitHub]1)3. Verification Commands が現在の canonical format に合っていない
現行の
issue-contract-reviewは、VC を## Verification Commands+ fenced bash block +$ ...command +# ACNとして扱う仕様です。非 fenced / inline / plain text は VC として認識しない、と明記されています。#589 の VC は通常の code block 風の記載で、$と# ACN対応もありません。([GitHub]4)このままだと、preflight が「VC なし」または「canonical でない VC」と判断する可能性が高いです。
4. Allowed Paths が広すぎる
#589 の Allowed Paths は以下を含みます。
特に
.claude/skills/**/tests/**は広すぎます。任意の skill test を変更できるため、PR が「関係ない test を追加して AC を満たしたふり」をしやすいです。#589 の実装対象は、少なくともissue-contract-reviewの preflight script / tests、VC authoring guidance、test-runner 手順に限定すべきです。([GitHub]1)5. AC5 “post-implementation discriminative check” が曖昧
#589 の核心はここです。現行
baseline_vc_preflight.pyには、rgが exit 1 の場合にexpected_baseline_failとして扱う分岐があります。これは「変更前に fail するから良い」というだけで、実装後に pass 可能かどうかを証明しません。#589 の問題意識と一致します。([GitHub]5)ただし、#589 の AC5 は「post-implementation discriminative check を required」と書くだけで、実装可能な判定基準がありません。ここは、以下のように機械判定可能にする必要があります。
6. “literal pipe intent annotation” の形式が未定義
AC3 は
rg -n "foo\|bar"を warning/block するとしつつ、literal pipe 意図がある場合は例外にしています。しかし、annotation の構文が定義されていません。これでは実装者が勝手にコメント形式を作り、reviewer / test-runner / preflight の間で解釈が割れます。推奨形式は、VC 直前の metadata comment に限定することです。
command 末尾 comment ではなく、直前 comment にすべきです。shell parsing と AC comment parsing を混ぜると、また判定器が壊れます。
技術レビュー
ripgrepはrg [OPTIONS] PATTERN [PATH...]の形で regex pattern を受け取り、デフォルトでは Rust regex engine を使います。Rust regex ではx|yは alternation です。さらに ASCII punctuation の escape は literal として扱われるため、\|は literal pipe 意味になります。つまり、#589 の前提である"foo|bar"と"foo\|bar"は意味が違う は正しいです。([manpages.debian.org]6)一方、shell pipe 判定は regex parser ではなく shell-like lexer の仕事です。現行
baseline_vc_preflight.pyはshlex.shlex(..., punctuation_chars=True)を使って|,&&,||,;などを検出しており、quoted string 内の|を shell operator と誤検出しない方向の設計になっています。Pythonshlexは Unix shell-like 構文用であり、Windows shell 互換ではありません。したがって #589 は「POSIX-like VC command grammar を対象」と明記すべきです。([GitHub]5)実装方針としては、
detect_compound_command()を regex 用に壊すべきではありません。shell pipe 検出と regex intent 検出は別レイヤーに分けるべきです。推奨する実装設計
1. shell operator detection は現行 shlex ベースを維持
次は shell pipe なので block。
cmd1 | cmd2次は quoted regex pattern なので shell pipe ではない。
ここで
foo\|barを block/warn するのは shell pipe policy ではなく regex intent policy です。2. regex-bearing command classifier を追加
対象を最初は限定すべきです。
対象にするもの:
対象外にするもの:
#589 の Out of Scope は “full regex-engine compatibility” なので、初回実装で広げすぎるべきではありません。([GitHub]1)
3. pattern intent を分類
最低限の分類はこれで足ります。
[|]や[\|]は character class 内なので、literal_pipe_suspectedと同列にしない方がよいです。完全 regex parser は不要ですが、character class と escape parity だけは見ないと false positive が増えます。4. non-discriminative VC として扱う条件を明文化
以下は block にすべきです。
$ rg -n "foo\|bar" docs理由は、「foo または bar を探したい」のに literal pipe を探してしまっている可能性が高く、実装後も pass しない VC になりやすいからです。
許可する場合は、明示 annotation と fixture / 根拠が必要です。
5. test-runner には raw command + hash を要求
#589 の AC4 は「test-runner が VC を逐語実行し、削除・簡略化・置換を禁止」としています。これを prose だけにすると弱いです。実行ログに以下を要求すべきです。
現行 preflight 側には command hash を計算する関数があるため、これを reviewer/test-runner の証跡形式に流用できます。([GitHub]5)
#589 の差し替え VC 案
現在の #589 VC は
rgで文言存在を見るものが多く、挙動保証として弱いです。次のように、機能テストを主にしてください。追加すべき test case は最低限これです。
修正後の Issue contract 方針
#589 は次のように絞るのが妥当です。
Allowed Paths は広域 glob ではなく、少なくとも次のように限定すべきです。
issue-refinement-loopの rootSKILL.mdは薄い entrypoint なので、VCS001 の実装・説明が reference / script 側にあるなら、そちらを明示した方がよいです。([GitHub]7)結論
#589 の問題設定は正しいです。ただし、現在の Issue は 実装 Issue としては blocked です。
最小修正は以下です。
BODYEOF/gh issue create ...を削除する。$+# ACNに直す。literal-pipe annotationの構文を定義する。regex_literal_pipe_suspected/ fixture / annotation / blocked decision で機械判定可能にする。この修正後なら、#589 は #578/#587 で露呈した VC 品質問題への妥当な follow-up になります。
squne121 commentedon Jun 3, 2026
人間からのコメントです。
「issue-refinement-loop」内に作業に関わるコンテクストが存在するのは禁止。スコープ外なら別Issueで削除orサブエージェント側へ移行するIssueを検討。
issue-contract-review を検討する際は .claude/agents/issue-author.md の .claude/skills/create-issue や .claude/skills/edit-issue .claude/agents/issue-reviewer.md の.claude/skills/review-issue 側も検討してほしい。
squne121 commentedon Jun 3, 2026
#589 (comment)
判定: 人間コメントは妥当。#589 はそのまま実装すると責務境界を壊す可能性が高い。本文修正または follow-up 分離が必要。
#589 は VC の
|/\|判定改善を目的にしているが、In Scope / Allowed Paths に.claude/skills/issue-refinement-loop/**を含めている。これは「issue-refinement-loop は control-plane 専用 thin entrypoint で、判定ロジックを再実装しない」という現行設計と衝突する。([GitHub]1) ([GitHub]1) ([GitHub]2)敵対的レビュー
#589 の中核修正先は issue-refinement-loop ではなく、VC authoring / contract readiness / review pass-through / test-runner です。
issue-refinement-loopは planner / reviewer / worker の結果を consume するだけで、Step 2 でもissue-reviewerのstatusとverdictだけを routing し、domain judgment を再解釈しない設計になっています。ここに「rg の\|は literal pipe」などの作業コンテクストを置くと、薄い entrypoint を太らせる逆行になります。([GitHub]2)技術的には、ripgrep は regex pattern を検索し、既定で Rust regex engine を使う。Rust regex の syntax では
x|yは alternation です。したがってrg -n "foo|bar"は regex alternation として扱うべきで、shell pipeline とは別物です。([manpages.debian.org]3) ([docs.rs]4) 一方、Pythonshlexのpunctuation_chars=Trueは();<>|&を shell punctuation として扱うため、quote 内 regex と quote 外 shell operator の切り分けはshlextoken 単体ではなく「argv 上の pattern 引数が regex-bearing command の pattern slot にあるか」で判定する必要があります。([Python documentation]5)現行の
contract_readiness_check.pyは fenced bash block の VC を抽出し、shlex.shlex(..., punctuation_chars=True)で token 化して、compound operator があれば VCS001 /compound_command_disallowedにしています。ここに実装する場合も、rg/grep -E/perlの pattern 引数内|は operator ではない、ただし\|は alternation ではなく literal pipe 意図の可能性が高いため warning/block する、という command-aware な判定にすべきです。([GitHub]6)#589 の修正方針
#589 は次のように直すのが安全です。
.claude/skills/issue-refinement-loop/**を In Scope / Allowed Paths から外す。例外は「既存記述の削除」だけ。ただしそれは 実装: VC コマンドの正規表現メタ文字を shell pipe と誤判定しない検証を追加する #589 の VC regex 修正とは別責務なので、原則 follow-up Issue。
In Scope に追加すべき対象
.claude/skills/issue-contract-review/scripts/contract_readiness_check.py.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py.claude/skills/create-issue/references/body-authoring.md.claude/agents/issue-author.md.claude/skills/edit-issue/**.claude/skills/review-issue/**.claude/agents/issue-reviewer.md.claude/agents/test-runner.md理由は、
create-issue/edit-issue/issue-authorが VC を生成・修復し、review-issue/issue-reviewerが contract readiness の structured blocker を lossless pass-through し、issue-contract-reviewが実装前 preflight を持つためです。([GitHub]7) ([GitHub]8) ([GitHub]9) ([GitHub]10)create-issue/references/body-authoring.mdを SSOT にする。既に同ファイルには
rg "foo\|bar"は|に修正する、OR 演算子は|であり\|ではない、という記述があります。実装: VC コマンドの正規表現メタ文字を shell pipe と誤判定しない検証を追加する #589 ではここを拡張し、「literal pipe を本当に検索したい場合は annotation 必須」と明文化するのがよいです。([GitHub]8)issue-contract-reviewは実装前 preflight のみに絞る。同 skill は「実装着手直前の preflight」で、Issue 本文品質レビューは
review-issue、改善ループはissue-refinement-loopの責務と明記されています。ここに入れるのは VC 抽出・分類・readiness mapping であり、Issue 改善方針の自然言語コンテクストではありません。([GitHub]11) ([GitHub]11)別 Issue 化すべき内容
人間コメントの「
issue-refinement-loop内に作業に関わるコンテクストが存在するのは禁止」は、#589 の本筋ではなく workflow architecture cleanup です。別 Issue として切るべきです。提案タイトル:
提案 Outcome:
GitHub コメント案
このコメントでよいです。#589 は 「VC regex/pipeline 判定改善」 に絞り、
issue-refinement-loopの脱コンテクスト化は別 Issue に分離するのが一番安全です。[-]後で変えて1[/-][+]実装: VC コマンドの正規表現メタ文字を shell pipe と誤判定しない検証を追加する[/+]squne121 commentedon Jun 3, 2026
コントラクトスナップショット (Contract Snapshot) (2026-06-03T07:11:30Z)
全チェック通過。
status: goを発行します。issue-contract-reviewの VC 解析が regex-bearing command の pattern 内|を shell pipeline と誤判定せず、\|をregex_literal_pipe_suspectedとして分類できる状態rg -n "foo|bar"は VCS001 違反にならない(regex alternation として扱われる)cmd1 | cmd2は従来どおり VCS001 違反として検出されるrg -n "foo\|bar"がregex_literal_pipe_suspectedとしてblockedになるtest-runner.mdに VC 逐語実行・省略禁止が明記されているbaseline_vc_preflight.pyのregex_literal_pipe_suspected判定テストが PASS するuv run pytest .claude/skills/issue-contract-review/tests/test_vc_regex_pipe_semantics.py -v(AC1/AC2/AC3/AC6)rg -n "逐語実行|VC.*verbatim|verbatim.*VC" .claude/agents/test-runner.md(AC4)uv run pytest .claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py -v(AC5/AC7)uv run pytest .claude/skills/issue-contract-review/tests/ -v(AC7 回帰)pnpm typecheck/pnpm test/pnpm build.claude/skills/issue-contract-review/scripts/配下、.claude/agents/test-runner.md、.claude/skills/create-issue/references/body-authoring.md.claude/worktrees/issue-589-vc-shell-pipeworktree-issue-589-vc-shell-pipesqune121 commentedon Jun 3, 2026
implement-issue: 実装完了
PR を作成しました: #627
検証結果
pytest 82/82 PASS(新規 19 件 + 既存 63 件)、pnpm test 339/339 PASS、pnpm typecheck・build すべて PASS。
AC 達成状況
rg -n "foo|bar"は VCS001 違反にならない ✓(quoted 内|は regex alternation として扱われる)cmd1 | cmd2は従来どおり compound_command_disallowed ✓rg -n "foo\|bar"はregex_literal_pipe_suspected→blocked✓(# vc-regex-intent: literal-pipe-okannotation で免除可能)test-runner.mdに「VC 逐語実行規則」セクションを追加 ✓baseline_vc_preflight.pyがregex_literal_pipe_suspectedを返すユニットテストが PASS ✓rg "foo|bar"は pass、rg "foo\|bar"→ blocked の fixture テストが PASS ✓fix: restore accidentally deleted fixture file (outside allowed paths)
squne121 commentedon Jun 3, 2026
PR #627 ブロッカー修正完了
pr-reviewer の REQUEST_CHANGES 2 件を修正しました。
ブロッカー 1: fixture ファイル復元
tests/fixtures/agent-session-manifest/temp-invalid-no-markers.mdを main から復元4dd89dc: fix: restore accidentally deleted fixture file (outside allowed paths)ブロッカー 2: Safety Claim Matrix 追加
## Safety Claim Matrixセクションを追加回帰確認
uv run pytest .claude/skills/issue-contract-review/tests/ -v→ 82/82 PASSpush
worktree-issue-589-vc-shell-pipebranch へ push 済みfix(#589): annotation scope leak, fixed-string false positive, path/g…
feat: VC regex pipe semantics — quoted | を shell pipe と誤判定しない検証を追加 (#589
squne121 commentedon Jun 3, 2026
PR #627 がマージされたためクローズします。
feat(#648): baseline_vc_preflight に rg_option_mismatch / broad_search…
fix: PR #2796 review fix_delta P1-A/P1-B/P2 (punctuation-run compound…
fix: baseline_vc_preflight の通常実行を shared VC parser に統一する (#2796)