Skip to content

feat: baseline VC preflight helper script を issue-contract-review と impl-review-loop で共有する #234

Closed

Description

@squne121
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "baseline VC preflight helper script を SSOT 化し、issue-contract-review と impl-review-loop で共有する"
change_kind: workflow
status: superseded
superseded_by:
  issues:
    - "#329"
  prs:
    - "#354"
  tracker: "#244-B"

Status

Superseded — #244 Track B / #329 / PR #354 に吸収・実装済み(merged 2026-05-24)。

このIssueの元契約(- リスト形式 VC 抽出)と現行実装(extract_fenced_bash_blocks())に仕様差分があります。
残課題は follow-up Issue で追跡します。

Parent Issue

none

Parent Goal Ref

  • Goal: VC 実行のワンライナー && 連鎖による途中停止を防ぎ、Issue 本文からの VC 抽出・実行・分類を共通スクリプトに集約する
  • Desired Destination: N/A(standalone improvement)

Current Validated Scope

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.sh(または Python helper)の新規作成
  • issue-contract-review / impl-review-loop からの共有呼び出し記述

Remaining Parent Gaps

なし

Outcome

.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.sh(または Python helper)が Issue 本文から VC を抽出して 1 つずつ実行・分類するロジックを提供し、issue-contract-review と impl-review-loop が同一スクリプトを呼び出す。

実装済み: baseline_vc_preflight.py は PR #354 で main にマージ済み(2026-05-24)。ただし実装は extract_fenced_bash_blocks() で fenced bash block を抽出する形式を採用しており、本 Issue 元契約の「- リスト形式 VC 抽出」とは異なる。この仕様差分は follow-up で解消する。

In Scope

  • baseline_vc_preflight.sh または baseline_vc_preflight.py の新規作成
  • VC 抽出(- リスト + # AC<N> マーカー形式)ロジック
  • 1 コマンドずつ実行・PASS/FAIL 分類・結果出力ロジック
  • issue-contract-review SKILL.md への呼び出し手順追記
  • impl-review-loop SKILL.md への呼び出し手順追記

Out of Scope

  • CI/CD への組み込み
  • GitHub Actions workflow の変更
  • 既存のワンライナー実行ロジックの遡及修正

Acceptance Criteria

Verification Commands

# AC1: スクリプトの存在確認
test -f .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.sh || test -f .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py

# AC4: 両 skill からの参照確認
rg "baseline_vc_preflight" .claude/skills/issue-contract-review/SKILL.md .claude/skills/impl-review-loop/SKILL.md 2>/dev/null

Allowed Paths

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.sh
  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
  • .claude/skills/issue-contract-review/SKILL.md
  • .claude/skills/impl-review-loop/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • bash または Python スクリプト authoring
  • skill authoring(SKILL.md Markdown 構造)

Scope Delta(任意)

N/A

Source

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    agent/implementer
    triage-required
    workflow
    on May 23, 2026
  2. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    結論

    #234 単体のままなら REQUEST_CHANGES。
    ただし実装作業としては、#244 Track B / #329 / PR #354 に吸収され、baseline_vc_preflight.py はかなり改善された状態で main にマージ済みです。問題は、#234 の契約が古いまま Open / queued に残っており、実装済み成果物との仕様差分が整理されていないことです。#234 は「- リスト形式の VC 抽出」を明記していますが、現行実装は ## Verification Commands 内の fenced bash block を主対象にしているように読めます。ここは放置すると、今後の Issue authoring / contract review の判定基盤に仕様ドリフトを残します。([GitHub]1) ([GitHub]2) ([GitHub]3)

    参照関係の整理

    #234 の発端は、PR #226 の post-merge cleanup で観測された「手組み && ワンライナーが grep exit code で途中停止した」問題です。提案自体は妥当で、Issue 本文から VC を抽出し、1 コマンドずつ実行・分類する helper を issue-contract-review と impl-review-loop で共有する、というものです。([GitHub]4)

    その後 #244 で目的が「body-authoring の validator / linter / preflight script による機械検証」へリフレームされ、#234 は Track B の #329 に absorb されました。#244 は baseline_vc_preflight.py が VC を抽出・単体実行・分類し、両 skill が同一 JSON を参照することを最終像にしています。([GitHub]2) ([GitHub]2)

    PR #354 は #329 の実装 PR として merge 済みで、Issue body から VC を AC marker ごとに抽出し、subprocess.run(..., shell=False) で実行し、expected_fail / unexpected_pass / blocked / human_judgment に分類する CLI を追加しています。最終レビューでは C1–C6 と M1–M3 が解消され、29 tests passed / 1 skipped、AC1–AC11 strict VC pass、5 checks passed で main に merge されています。([GitHub]5) ([GitHub]5) ([GitHub]5)

    良い点

    subprocess.run() を使い、引数列を shell=False で渡す方向は正しいです。Python 公式 docs でも subprocess.run() は推奨 API とされ、capture_output や timeout の挙動も明記されています。また、引数は string より sequence が一般に望ましいと説明されています。([Python documentation]6)

    compound shell syntax の検出に shlex.shlex(..., posix=True, punctuation_chars=True) を使う修正も筋が良いです。Python docs は punctuation_chars=True により ();<>|& の連続を shell punctuation token として扱えると説明しています。ただし同じ docs は、これは full shell parser ではなく、戻った token に対する独自エラーチェックが必要だとも明記しています。([Python documentation]7)

    PR #354 のレビュー過程で、空抽出 fail-open、compound 実行前検出、exit code contract、PyYAML lazy import、human_judgment の fragment 保持、impl-review-loop 側の pass-only 続行など、重要な安全弁はかなり潰されています。特に blocked / human_judgment で impl-review-loop を止める修正は、このスクリプトを workflow gate として扱うなら必須です。([GitHub]5)

    ブロッカー

    1. #234 の literal contract と現行成果物が一致していない

    #234 は In Scope / AC で「- リスト + # AC<N> marker 形式」から VC を抽出できることを要求しています。([GitHub]1)
    一方、現行 baseline_vc_preflight.py は extract_fenced_bash_blocks() で fenced bash block を抽出し、そこから $ prefix 行や非コメント行を command として parse する構造に見えます。([GitHub]3)

    これは「実装が悪い」というより、#234 が #329 に吸収された後の契約変更が #234 側に反映されていないことが問題です。選択肢は二つです。

    1. 互換性重視なら、- list parser を追加する。
    2. fenced bash block を正規仕様にするなら、feat: baseline VC preflight helper script を issue-contract-review と impl-review-loop で共有する #234 を superseded by #329/#354 として閉じ、docs: body-authoring.md に VC authoring format (リスト形式 + # AC<N> マーカー) を明文化する #229 / body-authoring / validator 側に「VC は fenced bash block が正」と明記する。

    現状のままでは、#234 を見た実装者が bullet-list VC を出し、preflight が 0 件抽出で blocked になるか、逆に validator と preflight の責務がずれます。

    2. 任意コマンド実行の threat model がまだ弱い

    shell=False は shell injection の面では改善ですが、Issue body に書かれた任意の first argv は実行されます。Python docs でも Popen は child program を実行し、sequence の最初の item が実行対象になると説明しています。([Python documentation]6)
    現行コードも shlex.split(command) した argv を subprocess.run(..., shell=False, cwd=args.cwd) に渡しています。([GitHub]3)

    これは CI/CD 組み込み外であっても危険です。人間や agent がローカル worktree で実行する前提なら、rm / git push / gh api / curl / bash / python -c のような副作用系をどう扱うかの policy が必要です。

    修正案:

    • --policy strict を default にする。
    • allowlist は rg, grep, test, python -m py_compile, pytest, uv run pytest, pnpm typecheck/lint/test/build 程度に限定。
    • bash, sh, python -c, node -e, curl, wget, gh api, git push, rm, mv, chmod, chown, dd, redirect, pipe, xargs は blocked。
    • --allow-mutating を明示指定しない限り mutation 系は実行しない。
    • --cwd が repo root であることを検証し、/, $HOME, /tmp などを拒否する。

    3. command substitution / negated search の static go は危険

    現行コードは $(...), backtick, ${...} を検出すると、実行せず expected_fail / expected_baseline_fail / go にしているように見えます。また ! rg / ! grep のような negated search も static に expected_fail / go へ分類しています。([GitHub]3)

    これは fail-closed の観点で弱いです。shell=False では ! や $() は shell syntax として評価されません。したがって「shell なら失敗期待」という人間の意図を、実行せず go にするのは、壊れた VC を正当化する分類になり得ます。shlex docs も shell-like parser であって full shell parser ではないため、独自エラーチェックが必要だとしています。([Python documentation]7)

    修正案:

    • $(...), backtick, ${...} は unsupported_shell_syntax / blocked。
    • ! rg PATTERN FILE を許可したいなら、shell として実行せず、内部 DSL として rg PATTERN FILE を実行し、exit 1 を expected_fail、exit 0 を unexpected_pass に反転分類する。
    • ! を単に prefix として検出して go にする実装は禁止。

    4. errors[] が #244 の “failing rule + minimal_context” 契約に対して弱い

    #244 は、AI に渡す修正コンテキストを validator JSON の failing rule + minimal_context に限定することを目標にしています。([GitHub]2)
    しかし現行コードの retrieval / extraction error は、少なくとも表示上は errors: ["Verification Commands section not found"] や ["No verification commands extracted ..."] のような string array です。([GitHub]3)

    これは人間には読めますが、修正 agent には弱いです。最低限、次の schema に寄せるべきです。

    {
      "kind": "vc_extraction_error",
      "rule": "verification_commands.fenced_bash_required",
      "message": "No verification commands extracted",
      "minimal_context": {
        "section": "## Verification Commands",
        "expected_format": "fenced bash block with # AC<N> markers"
      },
      "fix_hint": "Wrap VCs in ```bash and add # AC<N> markers"
    }

    追加の中リスク指摘

    gh issue view --json body --repo 経路自体は妥当です。GitHub CLI docs は gh issue view {number|url}、--json <fields>、--repo <OWNER/REPO> をサポートしています。([GitHub CLI]8)
    ただし PR #354 の最終レビューでも、実 GitHub 呼び出しの integration は auth 必要で 1 skipped、--issue --repo 経路の test は deterministic に寄せた部分的検証とされています。CI では mock test を必須化し、任意で GH_TOKEN ありの e2e を別 job にする方が堅いです。([GitHub]5)

    また、最終レビューでは expected_baseline_fail は argv[0] basename + stderr 条件へ修正済みとされていますが、現行 raw 表示上は if "rg " in command and exit_code == 1 や any(util in command for util in [...]) の substring 判定もまだ見えます。これは path / argument 内の偶然一致を拾う余地があります。実コードの改行が raw 表示で潰れているため断定は避けますが、少なくとも追加テストで固定すべきです。([GitHub]3) ([GitHub]5)

    推奨する次アクション

    1. feat: baseline VC preflight helper script を issue-contract-review と impl-review-loop で共有する #234 をそのまま実装 Issue として扱わない。
      superseded by #329/#354 と明記し、導入: Issue/PR body authoring 機械検証化 親トラッカー — validator・linter・preflight スクリプトによる体系的品質保証 #244 Track B に吸収済みとして close する。ただし、bullet-list VC 互換を捨てるなら、その理由と新 canonical format を残す。

    2. follow-up Issue を 1 本切る。
      タイトル例:
      fix: baseline_vc_preflight.py の VC format contract と unsafe command policy を明文化・強制する

    3. 修正対象を明確化する。

      • bullet-list VC を support するか、明示的に reject して fix_hint を返す。
      • unsupported shell syntax を static go にしない。
      • command allowlist / denylist / mutation policy を導入する。
      • errors[] を structured error にする。
      • JSON Schema を追加し、contract-review-fragment との parity test を golden fixture 化する。

    最終 verdict

    #354 の実装品質は、初期案からは大幅に改善済み。
    しかし #234 の契約管理としては未完了 です。特に「- list VC」対「fenced bash VC」の仕様差分と、Issue body 由来コマンドをローカルで実行する security boundary が未整理です。

    私なら、#234 には以下のコメントを付けます。

    #234 is absorbed by #244-B / #329 and implemented by #354. Do not treat this issue’s original bullet-list VC contract as the current implementation contract unless backward compatibility is explicitly required. Before closing, either add bullet-list extraction compatibility or document fenced bash VC as the canonical format and create a follow-up for unsafe-command policy / structured extraction errors.

  3. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Superseded by #329/#354. Closing as absorbed into #244-B.

  4. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了レポート

    LOOP_TERMINATION_RESULT_V1:
      termination_reason: superseded_by_decision
      iteration: 0
      max_iterations: 3
      anchor_comment:
        url: "https://github.com/squne121/loop-protocol/issues/234#issuecomment-4582564714"
        final_classification: superseded_by_decision
        classification_reason: "オーナーコメントにより #244-B/#329/PR #354 への吸収が確認。実装済み成果物と #234 契約の仕様差分を記録し close。"
      superseded_decision:
        decision_summary: "PR #354 (merged 2026-05-24) で baseline_vc_preflight.py 実装済み。#234 元契約(bullet-list VC 抽出)と現行実装(fenced bash block 抽出)に差分あり。"
        superseded_by_issues: ["#329"]
        superseded_by_prs: ["#354"]
        tracker: "#244-B"
      actions_taken:
        - "Issue 本文を superseded 状態に更新(AC チェックボックス反映、VC を fenced bash block 形式に修正)"
        - "Issue を closed/completed として close"
        - "Follow-up Issue #514 を起票"
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - number: 514
          url: "https://github.com/squne121/loop-protocol/issues/514"
          title: "fix: baseline_vc_preflight.py の VC format contract と unsafe command policy を明文化・強制する"
          dedupe_key: "baseline-vc-preflight-contract-and-safety-policy"
          status: created
          rationale: "anchor comment(#234#issuecomment-4582564714)が推奨。VC format contract の不一致・unsafe command policy・error schema 構造化を解消する。"
      note_only_observations: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationstate/queuedtriage-requiredworkflow

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions