Skip to content

実装: issue-contract-review に VC failure root cause 分類ステップを追加する #43

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "issue-contract-review に VC failure root cause 分類を追加する"
change_kind: workflow

Parent Issue

なし(単独改善)

Parent Goal Ref

Current Validated Scope

  • .claude/skills/issue-contract-review/SKILL.md の Procedure ステップ 3「VC preflight」に「VC failure root cause 分類」サブステップを追加
  • 分類ルール(正規表現マッチベースの軽量分類)を明文化:
    • file_not_found_expected: test -f / test -d 等の存在確認コマンドが exit 1 + empty stderr → 期待通り baseline fail
    • file_not_found_unrunnable: コマンド実行対象ファイルが欠損(No such file or directory + 実行対象が missing)→ 想定外、BLOCKED
    • env_missing_dep: No module named|ModuleNotFoundError|ImportError|command not found|not found|ERR_MODULE_NOT_FOUND|Permission denied|is not executable を含む、または exit 126/127 → 想定外、BLOCKED
    • expected_baseline_fail: grep/rg 系 exit 1 + no match、count assertion が threshold 未満 → 期待通り
    • unknown: 上記いずれにも該当しない → human_judgment(自動 GO しない)

Remaining Parent Gaps

なし

Outcome

issue-contract-review skill SKILL.md の Procedure ステップ 3 に「VC failure root cause 分類」サブステップが追加され、5 分類のいずれかを CONTRACT_REVIEW_RESULT_V1.checks.vc_preflight.classifications 配下に出力する手順が明示されたコミットが main にマージされている。

In Scope

  • issue-contract-review/SKILL.md Procedure ステップ 3 への分類サブステップ追加
  • 出力 schema (CONTRACT_REVIEW_RESULT_V1) への classifications フィールド追加(VC 単位 evidence 付き配列、既存 field を破壊しない)

Out of Scope

  • 分類ロジックの Python script 化(SKILL.md 内 bash 例示で十分)
  • 過去 Issue への遡及適用
  • review-issue skill の判定ロジック変更

Acceptance Criteria

  • AC1: issue-contract-review/SKILL.md の Procedure ステップ 3 内に「VC failure root cause 分類」サブステップが存在する
  • AC2: 5 分類(file_not_found_expected / file_not_found_unrunnable / env_missing_dep / expected_baseline_fail / unknown)がそれぞれ SKILL.md 内に明記されている
  • AC3: CONTRACT_REVIEW_RESULT_V1 の出力スキーマに vc_preflight.classifications フィールドが追加されている
  • AC4: env_missing_dep 分類時は BLOCKED 判定の判定基準として明示されている
  • AC5: ModuleNotFoundError または No module named を stderr に含む VC fail は env_missing_dep に分類され BLOCKED 判定になることが明示されている
  • AC6: grep/rg 系コマンドの exit 1 + no match は expected_baseline_fail として扱われることが明示されている
  • AC7: コマンド実行対象ファイルが欠損した場合は file_not_found_unrunnable として BLOCKED 判定になることが明示されている
  • AC8: unknown 分類は自動 GO ではなく human_judgment として明示されている

Verification Commands

  • rg -n "root cause|分類|classifications" .claude/skills/issue-contract-review/SKILL.md — # AC1: サブステップ存在
  • rg -n "file_not_found_expected|file_not_found_unrunnable|env_missing_dep|expected_baseline_fail|unknown" .claude/skills/issue-contract-review/SKILL.md | wc -l | awk '$1 >= 5 {print "OK"; exit} {print "FAIL"; exit 1}' — # AC2: 5 分類記載
  • rg -n "classifications" .claude/skills/issue-contract-review/SKILL.md — # AC3: schema 追加確認
  • rg -n "env_missing_dep.*BLOCKED|BLOCKED.*env_missing_dep" .claude/skills/issue-contract-review/SKILL.md — # AC4: BLOCKED 判定基準明示
  • rg -n "ModuleNotFoundError|No module named" .claude/skills/issue-contract-review/SKILL.md — # AC5: Python env 欠損検出語
  • rg -n "expected_baseline_fail" .claude/skills/issue-contract-review/SKILL.md — # AC6: grep/rg no-match 分類
  • rg -n "file_not_found_unrunnable.*BLOCKED|BLOCKED.*file_not_found_unrunnable" .claude/skills/issue-contract-review/SKILL.md — # AC7: unrunnable BLOCKED
  • rg -n "unknown.*human_judgment|human_judgment.*unknown" .claude/skills/issue-contract-review/SKILL.md — # AC8: unknown non-GO

Allowed Paths

  • .claude/skills/issue-contract-review/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • 分類ロジックを Python script 化する必要が出た場合(別 Issue 化)
  • 出力スキーマの破壊変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合
  • 外部サービス利用・権限昇格が必要になった場合
  • nested SubAgent delegation が必要になった場合
  • 既存テスト大規模改変が必要になった場合

Required Skills

なし

Notes for Reviewer

観測元: PR #38 観測メモ section D。Issue #33 AC9 baseline fail で warning として GO 判定したが、env 不備は本来 BLOCKED が望ましい。

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    agent/implementer
    on May 19, 2026
  2. squne121 commented on May 19, 2026

    @squne121
    OwnerAuthor

    着手タイミングに関する注記 (from PR #80 / Issue #72)

    PR #80 (Issue #72「DoR 基準明文化 A1」、merged 2026-05-19) で .claude/skills/issue-contract-review/SKILL.md を更新済みです(Related セクションに docs/dev/dor.md への参照リンクを追加)。

    本 Issue #43 と Allowed Paths が重複するため、以下の順序を推奨します:

    また、Issue #86(PR #80 follow-up: dor.md 軽微 polish)と Issue #43 の Allowed Paths は重複しません(#86 は dor.md のみ)。

    参照:

  3. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結論

    Issue #43 は方向性は正しいです。PR #38 / Issue #33 で実際に「pyyaml 未導入による baseline fail」を warning GO にしており、issue-contract-review の VC preflight 判定精度を上げる必要があります。PR #38 の観測メモ D でも、この改善は明示的に提案されています。

    ただし、現状の Issue #43 はこのまま実装すると誤判定を固定化するリスクが高いです。特に file_not_found と unknown の扱いは修正すべきです。


    Blocker 1: file_not_found の扱いが Issue 内で矛盾している

    Issue #43 の Parent Goal では「想定外 fail(env / file_not_found)」を区別して BLOCKED 精度を上げる、と書いています。
    しかし Current Validated Scope では、file_not_found: No such file or directory を含む → 期待通り baseline fail としています。

    これは矛盾です。

    No such file or directory は、少なくとも次の 2 種類があります。

    1. 期待通り: test -f 新規追加予定ファイル が exit 1 になる

    2. 想定外: python missing_script.py / cat missing_file / rg pattern missing_dir など、VC 自体の参照先が壊れている

    したがって、stderr の文字列だけで file_not_found を期待 fail 扱いするのは危険です。command family + exit_code + stderr + VC の意図 を組み合わせる必要があります。

    修正案:

    file_not_found_expected:
    condition:
    - command is existence assertion, e.g. test -f, test -d, [ -f ... ], [ -d ... ]
    - exit_code == 1
    - stderr is empty or non-fatal
    verdict: expected_baseline_fail

    file_not_found_unrunnable:
    condition:
    - stderr contains "No such file or directory"
    - command execution target, script path, cwd, or searched directory is missing
    verdict: BLOCKED


    Blocker 2: unknown -> warning GO は preflight の責務と逆向き

    Issue #43 は unknown を「warning として GO」にしています。
    これは issue-contract-review の位置づけと整合しません。

    現行 issue-contract-review は、実装着手直前に Issue を「このまま implement-issue に渡せるか」判定する preflight skill です。現行 Step 3 でも「実行不可能(コマンド不在 / ファイル不在)は BLOCKED」と定義されています。

    さらに DoR では、VC の失敗が「実装不足」ではなく「VC 設計ミス」に起因しないかは確認対象です。

    unknown は「実装不足による期待 fail」と証明できていない状態です。したがって安全側に倒すなら human_judgment または BLOCKED が妥当です。

    修正案:

    unknown:
    verdict: human_judgment
    next_action: propose_refinement_loop
    rationale: "実装不足による baseline fail と証明できないため、自動 GO しない"

    どうしても運用摩擦を下げたい場合でも、unknown を GO にする条件は「全 VC のうち unknown が非クリティカルで、他の VC が十分に fail-as-expected を示している」などの明示条件が必要です。


    Blocker 3: expected_baseline_fail の判定が rg 0 hit 等 だけでは粗すぎる

    Issue #43 は expected_baseline_fail を「rg 0 hit 等、追加実装で pass する想定」としています。
    しかし grep 系コマンドの exit code は意味を持ちます。GNU grep では、通常 0 = 行が選択された, 1 = 行が選択されなかった, 2 = error です。

    つまり、grep/rg 系で期待 baseline fail と見なせるのは主に exit 1 + no match であって、exit 2 や stderr ありは別扱いです。

    修正案:

    expected_baseline_fail:

    • command_family: grep_like
      exit_code: 1
      stderr_pattern: "^$|non-fatal warnings only"
      meaning: "pattern not found"
    • command_family: test_existence
      exit_code: 1
      stderr_pattern: "^$"
      meaning: "expected file/dir not present yet"
    • command_family: count_assertion
      exit_code: 1
      stdout_or_script_logic: "count below threshold"
      meaning: "required token/schema not yet present"

    Major: env_missing_dep の検出語彙が不足している

    Issue #43 の env_missing_dep は No module named|command not found|not provided by package だけです。
    これは狭すぎます。

    最低限、以下を追加した方がよいです。

    ModuleNotFoundError
    ImportError
    No module named
    Cannot find module
    ERR_MODULE_NOT_FOUND
    command not found
    not found
    No such file or directory.*(node|pnpm|python|uv|pytest|ruff|tsc|vite)
    Permission denied
    is not executable

    Python では ModuleNotFoundError は ImportError のサブクラスで、import 対象の module が見つからない場合に発生します。
    Bash では、コマンドが見つからない場合は exit status 127、見つかっても実行不能なら 126 が使われます。

    したがって、env_missing_dep は文字列 regex だけでなく exit code 126/127 も見るべきです。


    Major: Issue #33 / PR #38 の実例に対して AC が弱い

    Issue #33 の AC9 は uv run python -m pytest tests/ でしたが、実際には pyyaml が不足し、PR #38 では uv run --with pytest --with pyyaml python -m pytest tests/ によって PASS しています。

    uv の公式ドキュメントでも、uv run --with により invocation ごとに追加依存を要求できると説明されています。

    Issue #43 の AC は「分類名が書いてあること」だけなので、Issue #33/PR #38 の実例に対する回帰防止になっていません。

    追加すべき AC:

    • AC5: ModuleNotFoundError: No module named 'yaml' または No module named yaml を含む VC fail は env_missing_dep に分類され、BLOCKED 判定になる
    • AC6: grep / rg 系の no-match exit 1 は expected_baseline_fail に分類され、GO 可能な baseline fail として扱われる
    • AC7: python missing_script.py / cat missing_file など実行対象ファイル欠損は file_not_found_unrunnable として BLOCKED になる
    • AC8: unknown 分類は自動 GO ではなく human_judgment または BLOCKED に接続される

    Major: classifications schema が集計しか想定していない

    Issue #43 は CONTRACT_REVIEW_RESULT_V1.checks.vc_preflight.classifications の追加を求めています。
    しかし、単なる分類数だけではレビュー不能です。VC 単位で「どのコマンドが、どの出力で、なぜその分類になったか」が必要です。

    推奨 schema:

    vc_preflight:
    passed: true | false
    vc_failed_as_expected:
    vc_passed_unexpectedly:
    vc_unrunnable:
    classifications:
    - ac: AC1
    command: "rg -n ..."
    exit_code: 1
    category: expected_baseline_fail
    confidence: high
    evidence:
    stdout_excerpt: ""
    stderr_excerpt: ""
    decision: go
    - ac: AC9
    command: "uv run python -m pytest tests/"
    exit_code: 1
    category: env_missing_dep
    confidence: high
    evidence:
    stderr_excerpt: "ModuleNotFoundError: No module named 'yaml'"
    decision: blocked

    これにより pr-review-judge や人間レビューが分類根拠を検証できます。


    関連 Issue / PR との整合

    Issue #33 / PR #38

    Issue #43 の直接の根拠です。PR #38 では、AC9 の baseline fail が環境依存か期待 fail かを判定できず、warning GO にしたことが観測されています。
    このため、Issue #43 は妥当な follow-up です。

    Issue #72 / PR #80

    PR #80 は docs/dev/dor.md を追加し、issue-contract-review/SKILL.md に DoR 参照を追加しています。
    Issue #43 のコメントにも、PR #80 が同じ SKILL.md を変更済みで、最新 main を base にすべきことが記録されています。

    現時点では PR #80 は merge 済みなので、Issue #43 は最新 main ベースなら衝突リスクは低いです。ただし、DoR 側は「VC preflight で baseline fail を確認する」と書くだけで root cause 分類までは定義していないため、Issue #43 の変更は SKILL.md 内に閉じてもよいです。

    Issue #76

    Issue #76 は state label 体系の再定義で、state/queued vs state/ready の役割分担を扱っていましたが、closed as not planned です。
    Issue #43 は state ラベルではなく VC preflight の失敗分類なので、直接依存は不要です。


    高品質化した推奨パッチ方針

    Issue #43 をそのまま実装するより、以下のように Issue 本文を修正してから実装した方がよいです。

    1. 分類を 4 種類から 5〜6 種類にする

    現行:

    file_not_found / env_missing_dep / expected_baseline_fail / unknown

    推奨:

    expected_baseline_fail
    env_missing_dep
    command_not_found
    file_not_found_expected
    file_not_found_unrunnable
    unknown_needs_human

    command_not_found は env_missing_dep に含めてもよいですが、exit 127 を明示的に扱えるので分けた方がレビューしやすいです。

    1. unknown は GO ではなく human_judgment

    unknown_needs_human:
    decision: human_judgment
    next_action: propose_refinement_loop

    1. AC を「記述存在確認」から「誤判定防止確認」に強化

    現行 AC1〜AC4 は rg で文字列があるかを見るだけです。これは実装品質を担保しません。

    最低限、AC5〜AC8 を追加してください。

    • AC5: Python import error (ModuleNotFoundError / No module named) は env_missing_dep として BLOCKED 判定になる
    • AC6: grep/rg no-match exit 1 は expected_baseline_fail として扱われる
    • AC7: 実行対象ファイル欠損は file_not_found_unrunnable として BLOCKED 判定になる
    • AC8: unknown は warning GO ではなく human_judgment または BLOCKED として明示されている
    1. Verification Commands も強化

    AC5

    rg -n "ModuleNotFoundError|No module named|env_missing_dep.*BLOCKED|BLOCKED.*env_missing_dep" .claude/skills/issue-contract-review/SKILL.md

    AC6

    rg -n "grep|rg|no match|exit[_ -]?code.*1|expected_baseline_fail" .claude/skills/issue-contract-review/SKILL.md

    AC7

    rg -n "file_not_found_unrunnable|No such file or directory.*BLOCKED|BLOCKED.*No such file or directory" .claude/skills/issue-contract-review/SKILL.md

    AC8

    rg -n "unknown.*human_judgment|human_judgment.*unknown|unknown.*BLOCKED|BLOCKED.*unknown" .claude/skills/issue-contract-review/SKILL.md


    最終判定

    Issue #43 は着手価値あり。ただし現行 contract のまま実装するのは非推奨。

    特に以下は修正してから着手すべきです。

    1. file_not_found を期待 fail と想定外 fail に分割する

    2. unknown -> warning GO をやめ、human_judgment または BLOCKED にする

    3. env_missing_dep に ModuleNotFoundError, exit 126/127, Node/npm 系 missing module を含める

    4. AC/VC を「分類名が書いてある」ではなく「Issue 実装: gemini-cli-headless-delegation のランタイムセットアップテンプレを整備し SubAgent 起動可能状態にする #33/PR feat: gemini-cli-headless-delegation ランタイムセットアップチェッカーを追加 #38 型の誤判定を防げる」検証にする

    5. classifications は集計ではなく VC 単位の evidence 付き配列にする

    この修正を入れれば、Issue #43 は issue-contract-review の安全性を実質的に上げる良い小粒改善になります。

  4. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    Issue 本文更新 — review-issue diff_proposal 適用

    issue-refinement-loop Step 4 として review-issue が返した diff_proposal を本文に反映しました。

    適用した変更

    B1 対処: file_not_found の意味論的矛盾を解消

    • file_not_found を file_not_found_expected(存在確認コマンドの期待通り fail)と file_not_found_unrunnable(実行対象ファイル欠損、BLOCKED)の 2 分類に分割
    • Parent Goal Ref の「想定外 fail」と Current Validated Scope の「期待通り」の矛盾を除去

    B2 対処: unknown を自動 GO から human_judgment に変更

    • BLOCKED 判定精度向上という目的に逆行する自動 GO を廃止
    • unknown 分類は human_judgment(自動 GO しない)と明示

    B3 対処: pyyaml 不足 → ModuleNotFoundError への回帰防止 AC を追加

    • AC5〜AC8 を新規追加
    • env_missing_dep の検出語を拡充(ModuleNotFoundError, ImportError, exit 126/127 等)
    • VC5〜VC8 を新規追加

    その他の更新

    • 分類数を 4 → 5 に更新(AC2, VC2, Outcome)
    • classifications フィールド説明に「VC 単位 evidence 付き配列」を追記(In Scope)

    バックアップ

    /tmp/issue_43_backup_20260521_142057.txt

  5. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-21T05:22:43Z)

    • iteration: 1
    • verdict: approve
    • termination_reason: approved

    改善履歴

    iteration 0 → 1 で以下を適用:

    1. 分類ルール修正(B1: file_not_found 矛盾解消): file_not_found を file_not_found_expected(test -f/test -d が exit 1 + empty stderr → GO)と file_not_found_unrunnable(実行対象ファイル欠損 → BLOCKED)に分割
    2. unknown 判定変更(B2): warning として GO → human_judgment(自動 GO 廃止)に変更
    3. env_missing_dep 検出語拡充: ModuleNotFoundError / ImportError / ERR_MODULE_NOT_FOUND / exit 126/127 を追加
    4. AC5〜AC8 追加(B3): PR feat: gemini-cli-headless-delegation ランタイムセットアップチェッカーを追加 #38 型回帰防止 AC(Python env 欠損、grep/rg no-match、unrunnable BLOCKED、unknown non-GO)を追加
    5. VC5〜VC8 追加: AC5〜AC8 に対応する決定論的 Verification Commands を追加
    6. In Scope 更新: classifications フィールドを「VC 単位 evidence 付き配列」として明記

    次アクション

    issue-contract-review 実行可能(着手前 preflight)

  6. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-21T05:26:15Z)

    • Outcome: issue-contract-review SKILL.md の Procedure ステップ 3 に「VC failure root cause 分類」サブステップが追加され、5 分類(file_not_found_expected / file_not_found_unrunnable / env_missing_dep / expected_baseline_fail / unknown)を CONTRACT_REVIEW_RESULT_V1.checks.vc_preflight.classifications 配下に出力する手順が明示されたコミットが main にマージされている
    • Acceptance Criteria: AC1〜AC8(8 件)
    • Verification Commands: VC1〜VC8(8 件、rg/grep 決定論的)
    • Allowed Paths: .claude/skills/issue-contract-review/SKILL.md
    • Worktree: .claude/worktrees/issue-43-issue-contract-review-vc-failure-root-ca
    • Branch: worktree-issue-43-issue-contract-review-vc-failure-root-ca
    • VC preflight: baseline fail = 8, 想定外 pass = 0, 実行不可 = 0
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-05-21T05:26:15Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/43
      checks:
        template_compliance: pass
        state_label: pass
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 8
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
        ac_verifiability: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  7. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-21T05:30:00Z)

  8. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-21T05:32:04Z)

    検証証跡

    • AC1〜AC8: 全 PASS
    • pnpm typecheck / lint / test / build: 全 PASS
    • pytest (gemini-cli): 21 tests PASS
    • Mergeable: CLEAN

    次アクション

    PR #122 はマージ可能状態です。人間がマージ判断してください。

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/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions