Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "244"
goal_ref: "issue-author / edit-issue が VC を baseline_vc_preflight.py 互換の単一コマンド + exit code 判定のみで出力するよう guardrail を追加する"
change_kind: docsParent Issue
Parent Goal Ref
- Goal: GitHub Issue/PR の body が validator / preflight スクリプトによって機械検証され、AI エージェントが最小コンテキストで修正できる状態にする(導入: Issue/PR body authoring 機械検証化 親トラッカー — validator・linter・preflight スクリプトによる体系的品質保証 #244)。
- Desired Destination: VC は
baseline_vc_preflight.pyで抽出・単体実行・分類され、issue-contract-review / impl-review-loop が同一 JSON を参照する。
Current Validated Scope
.claude/agents/issue-author.md: rewrite/edit 時に VC を「単一コマンド + exit code 判定」のみで出力する guardrail を AC/VC Reflection セクションに明文化する。compound shell 形式(&&/||/|/;/ heredoc)の入力を受け取った場合は AC を分割するか、guardrail 違反として書き出さないことを明記する。.claude/skills/edit-issue/scripts/guard-issue-body.py: 既存の AC-VC Alignment check と並ぶ新規 check「VC Compound Shell Disallowed」を追加し、detect_compound_commandと同等のパターン検出ロジックで VC セクションを lint して fail-close する。.claude/skills/edit-issue/tests/test_guard_issue_body.py: compound shell を含む VC fixture と単一コマンド VC fixture の双方を追加し、新 check の fail/pass 挙動を回帰テストする。
Remaining Parent Gaps
- 本 child は VC 出力側の guardrail。VC 抽出・分類側(
baseline_vc_preflight.py)は 導入: Issue/PR body authoring 機械検証化 親トラッカー — validator・linter・preflight スクリプトによる体系的品質保証 #244 child B(実装: baseline_vc_preflight.py を実装し VC を AC 別に単体実行・分類して JSON で返す — #244-B #329)の責務で本 Issue では扱わない。 create-issueskill 側の VC 生成テンプレ更新は別 follow-up(既存references/body-authoring.md改訂)として 導入: Issue/PR body authoring 機械検証化 親トラッカー — validator・linter・preflight スクリプトによる体系的品質保証 #244 配下で別 Issue 化可能。create-issue/SKILL.mdの compound VC 例示削除は本 Issue では扱わず、実装: issue-author / edit-issue の VC 出力に compound shell 禁止 guardrail を追加する #445 マージ後の blocking follow-up として別途起票する。
Outcome
.claude/agents/issue-author.md に「VC は単一コマンド + exit code 判定のみ」guardrail が明文化され、.claude/skills/edit-issue/scripts/guard-issue-body.py に compound shell 検出 check が追加され、.claude/skills/edit-issue/tests/test_guard_issue_body.py の新規回帰テストが PASS している状態のコミットが main にマージされている。
Background
#67 の issue-refinement-loop iteration(2026-05-28)で、issue-author が AC ごとの VC を cmd && echo "PASS: ACn" || echo "FAIL: ACn" という compound shell 形式で生成した。続く issue-contract-review の baseline_vc_preflight.py がこれを compound_command_disallowed カテゴリで blocked と判定し、impl-review-loop 着手が中断された(#67 (comment) )。
direct trigger は main thread が rewrite prompt に && echo "PASS" || echo "FAIL" を含めた指示だが、root cause は issue-author / edit-issue 側に baseline_vc_preflight 互換性 guardrail が存在せず、外部入力が無検証で VC として書き出される構造にある。baseline_vc_preflight.py の detect_compound_command と整合する lint を edit 経路に置くことで、VC 生成段階での fail-close を可能にする。
In Scope
.claude/agents/issue-author.mdのAC/VC Reflection & Rewrite Logicセクションに以下のサブルールを追加:- VC は単一コマンドのみ。
&&/||/|/;/ heredoc を含めない - 判定は exit code に委ねる(
echo "PASS" / "FAIL"を末尾に付けない) - 入力 rewrite payload に compound shell が含まれていても、issue-author は AC を分割するか、guardrail 違反として書き出しを中止する
- guardrail テキストには stable marker
VC_SINGLE_COMMAND_GUARDRAILを含める
- VC は単一コマンドのみ。
.claude/skills/edit-issue/scripts/guard-issue-body.pyに新規 check 関数を追加:## Verification Commandsセクションのコマンド行を抽出baseline_vc_preflight.pyのdetect_compound_commandと同等の検出ロジックを実装:- 禁止 operators:
&&,||,|,;,&,<<,<,>,>>,<<< shlex.shlex(command, posix=True, punctuation_chars=True)または同等のトークン化- parse error は fail-closed で compound と見なす
- quoted operator(例:
grep -E "foo|bar" file)は誤検出しない
- 禁止 operators:
- 違反 1 件以上で check 結果を fail とし、AC ラベル・行番号・違反 operator・raw command を出力
- check 名は
vc_compound_shell_disallowedとする - check 関数名は
guard_vc_compound_shell_disallowedとする(AC2/VC2 の stable identifier)
.claude/skills/edit-issue/tests/test_guard_issue_body.pyに以下のテストを追加:- compound shell を含む VC fixture で新 check が fail を返す
- 単一コマンド VC fixture で新 check が pass を返す
- テスト関数名は
test_guard_issue_body_rejects_compound_shell_vcとする(AC3/VC3 の stable identifier)
Out of Scope
baseline_vc_preflight.py自体の compound shell 対応拡張(実装: baseline_vc_preflight.py を実装し VC を AC 別に単体実行・分類して JSON で返す — #244-B #329 / 導入: Issue/PR body authoring 機械検証化 親トラッカー — validator・linter・preflight スクリプトによる体系的品質保証 #244 child B の責務)- 実装: impl-review-loop Step 5 に BEHIND 分岐と auto update-branch を追加し schema を拡張する #67 本体の修正(既に人間 contract repair 済み)
create-issueskill の VC 生成テンプレ更新(別 follow-up)issue-refinement-loopplanner / orchestrator の判定ロジック変更create-issue/SKILL.mdの compound VC 例示の削除(本 Issue では扱わない)
ブロッキング follow-up:create-issue/SKILL.mdは現在&&/||を含む compound shell を VC の例として明示している(行 120, 129)。本 Issue では扱わないが、実装: issue-author / edit-issue の VC 出力に compound shell 禁止 guardrail を追加する #445 マージ後に blocking follow-up として別 Issue を起票する必要がある。本 Issue の accept のみでは create-issue 経路からの再発防止は達成されない。
Acceptance Criteria
- AC1:
.claude/agents/issue-author.mdに stable markerVC_SINGLE_COMMAND_GUARDRAILを含む guardrail 記述が存在する - AC2:
.claude/skills/edit-issue/scripts/guard-issue-body.pyにguard_vc_compound_shell_disallowedcheck 関数が存在する - AC3:
.claude/skills/edit-issue/tests/test_guard_issue_body.pyにtest_guard_issue_body_rejects_compound_shell_vcテスト関数が存在する - AC4:
uv run pytest .claude/skills/edit-issue/tests/test_guard_issue_body.pyが PASS する
Verification Commands
# AC1
grep -F "VC_SINGLE_COMMAND_GUARDRAIL" .claude/agents/issue-author.md
# AC2
grep -F "guard_vc_compound_shell_disallowed" .claude/skills/edit-issue/scripts/guard-issue-body.py
# AC3
grep -F "test_guard_issue_body_rejects_compound_shell_vc" .claude/skills/edit-issue/tests/test_guard_issue_body.py
# AC4
uv run pytest .claude/skills/edit-issue/tests/test_guard_issue_body.pyAllowed Paths
.claude/agents/issue-author.md.claude/skills/edit-issue/scripts/guard-issue-body.py.claude/skills/edit-issue/tests/test_guard_issue_body.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Delivery Rule
1 Issue = 1 PR。worktree: .claude/worktrees/issue-<N>-vc-compound-guard。Draft PR 既定。baseline_vc_preflight.py の detect_compound_command(.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py)を検出ロジックの参照仕様とし、edit-issue 側で同等パターンを実装する(import せず重複定義を許容、または共通ヘルパー化は別 follow-up)。
Activity
squne121 commentedon May 28, 2026
結論: REQUEST_CHANGES
Issue #445 は方向性は正しいですが、このまま実装 Issue として流すと 「VC compound shell を禁止する Issue 自身が VC/preflight 契約を満たしていない」 という状態です。特にブロッカーは 3 点です。
baseline_vc_preflight.pyと完全一致していないブロッカー
B1. #445 の VC が preflight 非互換
#329 で作られた
baseline_vc_preflight.pyは、Issue body の## Verification Commandsから fencedbashcode block を抽出し、# AC<N>marker で AC 対応を読む仕様です。compound/multiline/heredoc はcompound_command_disallowedとして blocked に分類されます。([GitHub]1)しかし #445 の Verification Commands は fenced block ではなく、インデントコードブロックです。つまり「preflight 互換性を改善する Issue」なのに、Issue 自身が current validator/preflight contract に乗っていません。([GitHub]2)
修正案:
ただし、上記は最低限です。AC2/AC3 は grep だけでは「存在確認」しかできないため、後述の CLI 実行テストを追加すべきです。
B2. create-issue を Out of Scope にすると根本原因が残る
#445 は
.claude/agents/issue-author.mdと.claude/skills/edit-issue/scripts/guard-issue-body.pyを対象にしていますが、issue-author は新規 Issue 作成ではcreate-issue、既存 Issue 修正ではedit-issueを使う構造です。([GitHub]3)その一方で、現在の
create-issue/SKILL.mdは Verification Commands の例としてpnpm typecheck && pnpm lint && pnpm test && pnpm buildを許容し、さらに削除確認例としてgrep ... && echo "FAIL" || echo "PASS"型を明示しています。これは #67 で実際に問題になった compound shell と同型です。([GitHub]4)#445 は create-issue template update を Out of Scope / follow-up possible にしていますが、これは弱いです。新規 Issue 生成経路が compound shell を教え続けるため、edit-issue 側だけを固めても再発防止になりません。([GitHub]2)
修正方針はどちらかに絞るべきです。
create-issue/SKILL.md、create-issue/references/body-authoring.md、create-issue/scripts/validate_issue_body.py、対応テストを追加する。B3. compound 判定仕様が baseline とズレる
#445 は禁止対象として
&&,||,|,;, heredoc を挙げています。([GitHub]2)しかし現行
baseline_vc_preflight.pyのdetect_compound_commandは、&&,||,|,;,&,<<,<,>,>>,<<<を対象にし、shlexparse error も fail-closed で compound 扱いにしています。([GitHub]5)Python の
shlex.shlex(..., punctuation_chars=True)は();<>|&を punctuation token として扱うため、この実装方針自体は妥当です。([Python documentation]6) Bash 側でも;,&,&&,||,|は control operator / list / pipeline として exit status と制御フローを変えます。A && B || Cは if-then-else ではなく、ShellCheck も誤用を警告しています。([GNU]7)修正案として、#445 の In Scope に以下を明記してください。
追加すべき Acceptance Criteria
現在の AC は grep と pytest だけで、guard が実際に fail-close する保証が弱いです。#354 のレビューでは、compound 検出が「実行前に止まるか」「exit code contract が正しいか」「分類が contract snapshot と一致するか」まで詰められて、最終的に修正後マージされています。([GitHub]8)
#445 には最低限、次の AC を追加すべきです。
実装レビュー観点
guard-issue-body.pyは「Issue body を書き換える前の fail-closed gate」です。したがって、単に helper を追加するだけでは不足です。現在の guard は template / outcome / diff / AC-VC alignment 系の check を集約しているため、新 check が通常 path と issue_kind resolved path の両方で実行される必要があります。([GitHub]9)また、
baseline_vc_preflight.pyはsubprocess.run(..., shell=False)とshlex.splitを使う前提なので、VC 自体も shell 構文に依存しない単一コマンドに寄せるべきです。Python 公式ドキュメントも、引数列の利用とshlex.split()による tokenization 例を示しており、shell 機能が必要な場合だけshell=Trueを使う整理です。([Python documentation]10)Issue #445 への具体的な修正文
#445 の scope は次のように書き換えるのが安全です。
最終判断
この Issue は実装前に修正すべきです。
現状の #445 は「#67 の再発防止」という狙い自体は妥当ですが、実際には以下が残ります。
baseline_vc_preflight.pyと guard 側の compound operator set がズレる。したがって、#445 は 「edit-issue の局所修正」ではなく、「VC authoring contract を create/edit/preflight で同一化する Issue」 として再定義した方が品質が上がります。
squne121 commentedon May 28, 2026
Contract Review: BLOCKED (2026-05-29T00:00:00Z)
不足項目
B1. VC が 3 件 unexpected_pass(AC6 / AC8 / AC9)
以下の VC は実装前の現状でも exit code 0 になるため
unexpected_pass / blockedに分類されています。VC のパターンが広すぎて既存コードにマッチしています。AC6 VC(問題):
grep -E "line|operator|offending" .claude/skills/edit-issue/scripts/guard-issue-body.pyline、operatorは既存コードに多数含まれるため現状 pass してしまいます。修正案:
grep -E "vc_compound.*line|vc_compound.*operator|offending_operator"など、新機能固有の文字列に絞る。AC8 VC(問題):
grep -E "<<|>>>|&(?!&)|<[^<]|>[^>]" .claude/skills/edit-issue/scripts/guard-issue-body.py文字列リテラル内の
</>等が既存コードにマッチします。修正案:
grep -n "vc_compound_shell_disallowed"で新 check 関数が禁止する operator set 定数の存在を確認する形に変更。AC9 VC(問題):
grep -E "sys\.exit|exit_code|return.*1" .claude/skills/edit-issue/scripts/guard-issue-body.pysys.exitは既存コードに含まれます。修正案:
grep -n "vc_compound_shell_disallowed"を含む check の存在から CLI wiring を間接確認するか、AC9 の VC をuv run python .claude/skills/edit-issue/scripts/guard-issue-body.py --helpの exit code で確認する形に変更。B2. AC ラベルがすべて AC_UNKNOWN
baseline_vc_preflight.pyは# AC<N>コメント(コロンなし)でコマンドと AC を対応付けます。現在の VC は# AC1: 説明文形式(コロンあり + 日本語説明)のため、AC 番号がAC_UNKNOWNとして抽出されます。修正案: VC コメントを以下の形式に変更:
B3. branch 衝突
worktree-issue-445-vc-compound-guardbranch が既存です。前回の中断イテレーションの残骸の可能性があります。人間が確認・削除してから再実行してください。推奨アクション
issue-refinement-loopを起動して VC を修正してください(B1: AC6/AC8/AC9 の grep パターン修正、B2: AC ラベルのコロン除去)git branch -d worktree-issue-445-vc-compound-guardで残骸 branch を削除してからimpl-review-loopを再実行してくださいsqune121 commentedon May 28, 2026
修正補足(前コメントの B2 説明誤り訂正)
B2 の原因表現を訂正します。
baseline_vc_preflight.pyは# AC1と# AC1:の両方を許容しますが、許容されるのは単独コメント行のみです(regex:^\s*#\s*AC(\d+)\s*:?\s*$)。したがって
# AC1: 説明文が AC_UNKNOWN になる原因は「コロン」ではなく「同一行に説明文があること」です。前コメントの「コロンを除去する」は誤りでした。修正方針
## Verification Commandsは```bashfenced block に統一(対応済み)# AC1/# AC2の単独行にする(説明テキスト分離)line,operator,sys.exit)ではなく、新規実装に固有の stable identifier を使う推奨 AC/VC 修正案:
AC も stable identifier に対応させる必要があります:
.claude/agents/issue-author.mdに stable markerVC_SINGLE_COMMAND_GUARDRAILを含む guardrail 記述が存在する.claude/skills/edit-issue/scripts/guard-issue-body.pyにguard_vc_compound_shell_disallowedcheck 関数が存在する.claude/skills/edit-issue/tests/test_guard_issue_body.pyにtest_guard_issue_body_rejects_compound_shell_vcが存在するuv run pytest .claude/skills/edit-issue/tests/test_guard_issue_body.pyが PASS するbranch 残骸クリーンアップ手順
impl-review-loop再実行は上記 VC/AC 修正後に行ってください。squne121 commentedon May 28, 2026
Contract Snapshot (2026-05-29T00:00:00Z)
.claude/agents/issue-author.mdにVC_SINGLE_COMMAND_GUARDRAILguardrail 明文化、.claude/skills/edit-issue/scripts/guard-issue-body.pyにguard_vc_compound_shell_disallowedcheck 追加、.claude/skills/edit-issue/tests/test_guard_issue_body.pyの回帰テスト PASSgrep -F "VC_SINGLE_COMMAND_GUARDRAIL" .claude/agents/issue-author.mdgrep -F "guard_vc_compound_shell_disallowed" .claude/skills/edit-issue/scripts/guard-issue-body.pygrep -F "test_guard_issue_body_rejects_compound_shell_vc" .claude/skills/edit-issue/tests/test_guard_issue_body.pyuv run pytest .claude/skills/edit-issue/tests/test_guard_issue_body.py.claude/agents/issue-author.md.claude/skills/edit-issue/scripts/guard-issue-body.py.claude/skills/edit-issue/tests/test_guard_issue_body.py.claude/worktrees/issue-445-vc-compound-guardworktree-issue-445-vc-compound-guardsqune121 commentedon May 28, 2026
implement-issue: 実装完了 (2026-05-29T00:00:00Z)
.claude/worktrees/issue-445-vc-compound-guardworktree-issue-445-vc-compound-guardfix(#445): structured violations・name 統一・fence regex 修正・issue-author …
refactor(#445): issue-author.md の VC_SINGLE_COMMAND_GUARDRAIL を stabl…
fix(#445): shlex punctuation run token 検出(B4)と inline # ACN suffix 抽出…
feat(#445): issue-author に VC_SINGLE_COMMAND_GUARDRAIL を追加し guard-iss…