Skip to content

実装: new-file VC preflight を missing Allowed Paths file として決定論的に分類する #1328

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "baseline_vc_preflight.py の classify_result() が rg exit_code==2 を無条件に human_judgment/unknown へ落とす問題を解消し、Allowed Paths 内の新規ファイル missing を厳密証明できる場合だけ決定論的な expected fail category として扱えるようにする"
change_kind: code

Parent Issue

none

Parent Goal Ref

  • Goal: 新規ファイル追加を伴う implementation Issue で issue-contract-review の status:go が構造的に発行できない問題を解消する
  • Desired Destination: N/A(parent なし、単独改善)

Current Validated Scope

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py の classify_result() に、rg exit_code==2 を厳密条件下でのみ expected fail 化する分類ロジックを追加する
  • classify_result() の signature に allowed_paths が渡っていない問題を解消する(signature 拡張、または post-execution 判定を呼び出し側に移す)
  • _candidate_new_allowed_path_target() を _rg_has_broad_search_path() 相当の argv parser へ置換する
  • stderr 判定に whitelist(missing path 系)と blacklist(invalid regex / unsupported option / config error / permission denied)の両方を実装する
  • 対応するテストを .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py に追加する

Remaining Parent Gaps

なし

Outcome

.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py の classify_result() が更新され、rg が Allowed Paths 内の新規ファイル(未作成)に対して実行され exit_code 2 かつ stderr が missing path 系である場合にのみ expected_fail / go / 専用 category(new_file_missing_expected)を返し、.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py に追加されたテストが全件 PASS している状態。invalid regex / unsupported option / permission error / Allowed Paths 外 path は従来通り blocked または human_judgment のままであることもテストで固定されている。この判定には allowed_paths が classify_result() の判定経路に確実に渡り、path operand 抽出は _rg_has_broad_search_path() 相当の成熟した argv parser で行われる。

In Scope

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py の classify_result() に、rg exit_code == 2 を「missing Allowed Paths file と厳密に証明できる場合」だけ新規 category(new_file_missing_expected)として expected_fail/go に分類するロジックを追加する
  • 判定条件を実装する: (1) classify_static_command() を通過済み(static block されていない), (2) rg の path operand を安全な argv parser で抽出済みで missing と判定した path が全て normalized Allowed Paths 配下, (3) stderr が「対象 path が存在しない/読めない」系のパターンに限定され regex/config/option error でないこと
  • classify_result() の signature を拡張する(例: allowed_paths: list[str], cwd: Path, static_policy_passed: bool 等を追加する)か、または post-execution の分類判定を呼び出し側(main() 等)に移し、allowed_paths_from_body と static classification 結果を判定に利用できるようにする。いずれの方針を採るかは実装時に選択し、AC として固定する
  • _candidate_new_allowed_path_target()(現行 .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py L1701-1739)を維持・統合はせず、_rg_has_broad_search_path() 等で既に実装されている成熟した rg argv parser(-e/--regexp/--glob/--/複数path/value-taking-flags 対応)へ置換する。既存 _candidate_new_allowed_path_target() は wrapper 化または削除する
  • stderr 判定に whitelist だけでなく blacklist を実装する: invalid regex / unsupported option / config error / permission denied を示す stderr が含まれる場合は new_file_missing_expected にしない
  • 新規 category new_file_missing_expected を compute_confidence() の high confidence set に追加する
  • 上記変更に対応するテストを .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py に追加する

Out of Scope

  • allowed_paths_review_gate.py の fingerprint 必須要件(別 Issue で扱う)
  • issue-contract-review の他の gate ロジック全般の見直し
  • PR files API pagination 対応

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue の変更は classify_result() の分類ロジックと対応する pytest ユニットテストのみで完結し、プロセス起動・外部通信・I/O は不要(pnpm typecheck / lint / test / build と対象ファイルの pytest のみで検証が成立する)

Acceptance Criteria

  • AC1: rg が Allowed Paths 内の単一の新規ファイル(未作成)に対して実行され exit_code 2 かつ stderr が missing path 系である場合、classify_result() は expected_fail / go / 専用 category(new_file_missing_expected)を返す
  • AC2: rg の missing path のうち一つでも Allowed Paths 外の場合は、blocked または human_judgment のままであり、expected_fail にならない
  • AC3: rg が invalid regex(例: 閉じていない括弧)で exit_code 2 を返す場合、expected_fail にならず human_judgment または blocked のままである
  • AC4: rg が unsupported option(例: 存在しないフラグ)で exit_code 2 を返す場合、expected_fail にならず human_judgment または blocked のままである
  • AC5: rg コマンドが -e, --regexp, --glob, --, value-taking options, 複数 path を含む場合でも、path operand の抽出が誤判定しないことをテストで示す
  • AC6: 既存の test -f / test -d / test -s の file_not_found_expected 分類が回帰しないことをテストで示す
  • AC7: _candidate_new_allowed_path_target() を _rg_has_broad_search_path() 相当の argv parser へ置換する実装が行われ、そのテストが追加されている(既存 helper は維持・統合の対象にしない)
  • AC8: 上記すべてのテストが .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py に追加され pass する
  • AC9: classify_result() の判定経路に allowed_paths が確実に渡ること(signature 拡張 または post-execution 判定への移行のいずれか)がテストで示され、allowed_paths なしで stderr だけから new_file_missing_expected に分類されるケースが存在しないことがテストで固定されている
  • AC10: stderr に missing path 系のメッセージと invalid regex / unsupported option / config error / permission denied のいずれかが混在する場合、new_file_missing_expected に分類されないことをテストで示す
  • AC11: new_file_missing_expected category が compute_confidence() の high confidence set に含まれることをテストで示す

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC2
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC3
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC4
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC5
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC6
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC7
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC8
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

# AC9
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC10
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

# AC11
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

Allowed Paths

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
  • .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py

Stop Conditions

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

Required Skills

なし

Scope Delta(任意)

N/A

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jul 4, 2026
  2. squne121 commented on Jul 4, 2026

    @squne121
    OwnerAuthor

    判定

    要修正。#1328 の問題設定は正しいが、現 Issue 文のまま実装すると rg exit 2 の false-green を作る危険が残ります。
    #1328 は baseline_vc_preflight.py の classify_result() が rg exit_code == 2 を human_judgment/unknown に落とす問題を、Allowed Paths 内の新規ファイル missing と厳密証明できる場合だけ expected_fail/go にする Issue です。Issue コメントは現時点で 0 件です。

    今回確認した範囲は、#1328、関連 #1324 / #1281 / #1329、PR #1318、baseline_vc_preflight.py、既存テスト、ripgrep 公式仕様、Python の shlex / path 正規化仕様です。ローカルでのテスト実行はしていません。

    根本問題の整理

    #1328 の前提は妥当です。現行 classify_result() は rg の no-match、つまり exit_code == 1 だけを expected_fail / expected_baseline_fail / go にし、rg exit_code == 2 には専用分岐がありません。最終的に human_judgment / unknown に落ちます。

    一方、ripgrep 仕様上、exit status は「match あり = 0」「match なし = 1」「error = 2」です。さらに exit 2 は regex syntax error のような catastrophic error と、ファイルが読めない soft error の両方を含みます。したがって、exit_code == 2 を一括で expected fail にする実装は不可です。(Debian Manpages)

    PR #1318 はこの問題の実例です。#1281 では新規ファイル src/systems/UpgradeSystem.ts 等を対象に rg -n ... の baseline VC が多数定義されており、新規ファイル未作成時に rg exit 2 になり得る構造でした。 PR #1318 側では最終的に実装・テスト・CI は通っていますが、review コメントでは allowed_paths_gate: indeterminate が blocker とされ、fresh fingerprint binding がないため worker self-report を正本にできない、と fail-closed されています。

    P0 指摘

    1. classify_result() だけを直す設計だと Allowed Paths 判定に必要な情報が足りない

    現行 classify_result() の signature は exit_code, stdout, stderr, command, cwd, runner_env_delta だけで、allowed_paths を受け取りません。 実行ループでも classify_result() 呼び出しに allowed_paths_from_body は渡されていません。

    #1328 は「missing path がすべて normalized Allowed Paths 配下」という条件を要求していますが、今の classify_result() 単体ではそれを証明できません。
    実装方針は次のどちらかに固定すべきです。

    • classify_result(..., allowed_paths: list[str], cwd: Path, static_policy_passed: bool) のように signature を拡張する

    • あるいは post-execution の分類を main() 側に寄せ、allowed_paths_from_body と static classification 結果を持った状態で rg exit 2 特例を判定する

    Issue 文には「classify_result() に追加」とありますが、このままだと実装者が allowed_paths なしで stderr だけを見て expected fail 化する余地があります。

    2. _candidate_new_allowed_path_target() は今回の判定エンジンに使ってはいけない

    現行 _candidate_new_allowed_path_target() は test なら非フラグ引数を全部候補、rg なら argv[1:] の非 option を集めて non_opt[1:] を path とみなします。 これは rg -e PATTERN PATH、--regexp=PATTERN、--glob GLOB、--、value-taking option、複数 path、pattern が - で始まるケースで誤判定します。

    一方、同じファイルには _rg_has_broad_search_path() があり、-e / --regexp / --regexp= / -ePATTERN、--glob / --iglob、value-taking flags、--、combined short flags を考慮して path args を抽出しています。

    #1328 の AC7 は「維持 / 統合 / 置換のいずれか」としていますが、敵対的には 置換一択 です。既存 helper は strict mode の「baseline-expect 未記載検出」には使われていますが、post-execution の rg exit 2 を go に昇格させる根拠としては弱すぎます。

    3. stderr 判定は whitelist + blacklist の両方が必要

    rg exit 2 の stderr が missing path 系であることだけでは不十分です。stderr に missing path と invalid regex / unsupported option / config error / permission denied が混在する可能性があります。ripgrep 仕様上、exit 2 は soft error と catastrophic error の両方を含むためです。(Debian Manpages)

    必要な分類条件は最低限これです。

    • exit_code == 2

    • command basename が rg

    • classify_static_command() が blocked を返していない

    • path operand が 1 個以上抽出できる

    • broad path ではない

    • stderr が missing path / cannot read target path 系に限定される

    • stderr に regex parse error、unsupported option、config parse error、permission denied が含まれない

    • missing と読める path がすべて Allowed Paths 内で、baseline cwd 上で未存在

    • stderr 内の missing path と argv path operands が対応している

    「一部 path だけ Allowed Paths 内」「一部だけ missing」「stderr に複数 error が混在」は expected_fail/go にしてはいけません。

    4. Allowed Paths containment は文字列 prefix だけでは弱い

    現行 helper の _in_allowed() は lstrip("./") と startswith(a + "/") で判定しています。 これは ..、絶対パス、symlink、Windows path 風入力、正規化前後の差分に弱いです。

    Python では os.path.commonpath() が「有効な共通パス」を返す API で、文字列 prefix の commonprefix() とは違います。(Python documentation) また PurePath.is_relative_to() は純粋に文字列ベースであり、.. や symlink 解決をしない点に注意が必要です。(Python documentation)

    この Issue では、少なくとも次の方針を AC に入れるべきです。

    • repo root / cwd を基準に path を正規化する

    • absolute path は原則 reject

    • .. で Allowed Paths 外へ抜ける path は reject

    • missing file 自体は resolve(strict=True) できないため、存在する親ディレクトリを基準に containment を判定する

    • 最終判定は commonpath() 相当で行い、単純 prefix だけにしない

    推奨実装仕様

    #1328 は次のように仕様を硬くしたうえで実装開始するのが安全です。

    1. _extract_rg_path_operands(argv) を追加し、_rg_has_broad_search_path() と new_file_missing_expected 判定の両方から使う。既存 _candidate_new_allowed_path_target() は wrapper 化または削除する。

    2. rg exit 2 特例は専用 helper に閉じ込める。

    _classify_rg_exit2_missing_allowed_path(
      command,
      exit_code,
      stderr,
      cwd,
      allowed_paths,
      static_result
    ) -> Optional[classification_tuple]
    
    1. 戻り値 category は expected_baseline_fail に混ぜず、new_file_missing_expected にする。既存 category に混ぜると、後で「no-match」と「new-file missing」の監査区別ができません。

    2. compute_confidence() の high confidence set に new_file_missing_expected を追加する。追加しないと contract-review fragment の confidence が low になり、別 gate で不要な揺れを生みます。

    3. allowed_paths_review_gate.py の fingerprint fallback は触らない。これは 実装: issue-contract-review fingerprint refresh path を明示する #1329 の範囲であり、実装: issue-contract-review fingerprint refresh path を明示する #1329 も fingerprint 必須要件を維持し、欠落時は indeterminate のまま action-oriented reason を返す方針です。

    追加すべきテスト

    既存テストには subprocess 経由で preflight を実行する helper があり、JSON を parse する形になっています。 現在は rg exit 1 の expected fail や exit code contract のテストはありますが、rg exit 2 の new-file missing 特例はまだありません。

    最低限、以下を追加してください。

    優先度 | ケース | 期待 -- | -- | -- P0 | rg -n quoteUpgrade src/systems/UpgradeSystem.ts、path は Allowed Paths 内、未存在 | expected_fail / new_file_missing_expected / go P0 | missing path が Allowed Paths 外 | expected_fail にならない P0 | rg -n '(' src/systems/NewFile.ts | invalid regex として human_judgment または blocked P0 | rg --include '*.ts' foo src/systems/NewFile.ts | static block、rg_option_mismatch P0 | rg foo . | broad_search_path_unbounded P0 | rg -n -e quoteUpgrade --glob '*.ts' src/systems/UpgradeSystem.ts tests/upgrade-system.test.ts | path operand 抽出が正しい P0 | rg --regexp=quoteUpgrade -- src/systems/UpgradeSystem.ts | -- 処理が正しい P0 | rg -n -- -foo src/systems/UpgradeSystem.ts | pattern が - 始まりでも path 誤判定しない P1 | --max-count 1、--type ts、--replace x、--color never など value-taking options | option value を path と誤認しない P1 | test -f / test -d / test -s 既存分類 | file_not_found_expected が回帰しない

    ripgrep は -e/--regexp で pattern を明示でき、pattern が - で始まる場合や複数 pattern の場合に使われます。また -- も同等の曖昧性回避に使われます。(Debian Manpages) -g/--glob は検索対象のファイルを glob で絞る option であり、path operand ではありません。(GitHub)

    #1328 本文への修正案

    現 Issue に追記するなら、次の4点です。

    1. classify_result() に allowed_paths が無い問題を明記
      classify_result() の signature 拡張、または main() 側 post-execution 判定への移動を AC に入れる。

    2. _candidate_new_allowed_path_target() は維持ではなく置換方針にする
      _rg_has_broad_search_path() 相当の argv parser を shared helper 化し、strict-mode の missing annotation 検出と rg exit2 分類の両方で使う。

    3. stderr 判定の blacklist を AC に入れる
      invalid regex / unsupported option / config error / permission denied / broad path / outside Allowed Paths は明示的に expected_fail 禁止。

    4. category と confidence の追加を AC に入れる
      new_file_missing_expected を fragment / confidence / schema consistency の対象として固定する。

    最終判断

    #1328 は 採用してよいが、そのまま実装プロンプトに渡すにはまだ危険 です。
    特に危険なのは「rg exit 2 を分類する」と言いながら、実際には classify_result() に Allowed Paths が渡っていない点と、既存 _candidate_new_allowed_path_target() が rg argv parser として未成熟な点です。

    実装者への指示は、次の一文に圧縮できます。

    rg exit 2 を expected fail にするのではなく、rg exit 2 のうち「static policy 通過済み・shared rg argv parser で抽出した missing path が全て normalized Allowed Paths 内・stderr が missing target 系のみ」と証明できるものだけを new_file_missing_expected として expected_fail/go に分類し、それ以外は従来通り fail-closed または human_judgment に残すこと。

    ## 判定

    要修正。#1328 の問題設定は正しいが、現 Issue 文のまま実装すると rg exit 2 の false-green を作る危険が残ります。
    #1328 は baseline_vc_preflight.py の classify_result() が rg exit_code == 2 を human_judgment/unknown に落とす問題を、Allowed Paths 内の新規ファイル missing と厳密証明できる場合だけ expected_fail/go にする Issue です。Issue コメントは現時点で 0 件です。

    今回確認した範囲は、#1328、関連 #1324 / #1281 / #1329、PR #1318、baseline_vc_preflight.py、既存テスト、ripgrep 公式仕様、Python の shlex / path 正規化仕様です。ローカルでのテスト実行はしていません。

    根本問題の整理

    #1328 の前提は妥当です。現行 classify_result() は rg の no-match、つまり exit_code == 1 だけを expected_fail / expected_baseline_fail / go にし、rg exit_code == 2 には専用分岐がありません。最終的に human_judgment / unknown に落ちます。

    一方、ripgrep 仕様上、exit status は「match あり = 0」「match なし = 1」「error = 2」です。さらに exit 2 は regex syntax error のような catastrophic error と、ファイルが読めない soft error の両方を含みます。したがって、exit_code == 2 を一括で expected fail にする実装は不可です。([Debian Manpages]1)

    PR #1318 はこの問題の実例です。#1281 では新規ファイル src/systems/UpgradeSystem.ts 等を対象に rg -n ... の baseline VC が多数定義されており、新規ファイル未作成時に rg exit 2 になり得る構造でした。 PR #1318 側では最終的に実装・テスト・CI は通っていますが、review コメントでは allowed_paths_gate: indeterminate が blocker とされ、fresh fingerprint binding がないため worker self-report を正本にできない、と fail-closed されています。

    P0 指摘

    1. classify_result() だけを直す設計だと Allowed Paths 判定に必要な情報が足りない

    現行 classify_result() の signature は exit_code, stdout, stderr, command, cwd, runner_env_delta だけで、allowed_paths を受け取りません。 実行ループでも classify_result() 呼び出しに allowed_paths_from_body は渡されていません。

    #1328 は「missing path がすべて normalized Allowed Paths 配下」という条件を要求していますが、今の classify_result() 単体ではそれを証明できません。
    実装方針は次のどちらかに固定すべきです。

    • classify_result(..., allowed_paths: list[str], cwd: Path, static_policy_passed: bool) のように signature を拡張する
    • あるいは post-execution の分類を main() 側に寄せ、allowed_paths_from_body と static classification 結果を持った状態で rg exit 2 特例を判定する

    Issue 文には「classify_result() に追加」とありますが、このままだと実装者が allowed_paths なしで stderr だけを見て expected fail 化する余地があります。

    2. _candidate_new_allowed_path_target() は今回の判定エンジンに使ってはいけない

    現行 _candidate_new_allowed_path_target() は test なら非フラグ引数を全部候補、rg なら argv[1:] の非 option を集めて non_opt[1:] を path とみなします。 これは rg -e PATTERN PATH、--regexp=PATTERN、--glob GLOB、--、value-taking option、複数 path、pattern が - で始まるケースで誤判定します。

    一方、同じファイルには _rg_has_broad_search_path() があり、-e / --regexp / --regexp= / -ePATTERN、--glob / --iglob、value-taking flags、--、combined short flags を考慮して path args を抽出しています。

    #1328 の AC7 は「維持 / 統合 / 置換のいずれか」としていますが、敵対的には 置換一択 です。既存 helper は strict mode の「baseline-expect 未記載検出」には使われていますが、post-execution の rg exit 2 を go に昇格させる根拠としては弱すぎます。

    3. stderr 判定は whitelist + blacklist の両方が必要

    rg exit 2 の stderr が missing path 系であることだけでは不十分です。stderr に missing path と invalid regex / unsupported option / config error / permission denied が混在する可能性があります。ripgrep 仕様上、exit 2 は soft error と catastrophic error の両方を含むためです。([Debian Manpages]1)

    必要な分類条件は最低限これです。

    • exit_code == 2
    • command basename が rg
    • classify_static_command() が blocked を返していない
    • path operand が 1 個以上抽出できる
    • broad path ではない
    • stderr が missing path / cannot read target path 系に限定される
    • stderr に regex parse error、unsupported option、config parse error、permission denied が含まれない
    • missing と読める path がすべて Allowed Paths 内で、baseline cwd 上で未存在
    • stderr 内の missing path と argv path operands が対応している

    「一部 path だけ Allowed Paths 内」「一部だけ missing」「stderr に複数 error が混在」は expected_fail/go にしてはいけません。

    4. Allowed Paths containment は文字列 prefix だけでは弱い

    現行 helper の _in_allowed() は lstrip("./") と startswith(a + "/") で判定しています。 これは ..、絶対パス、symlink、Windows path 風入力、正規化前後の差分に弱いです。

    Python では os.path.commonpath() が「有効な共通パス」を返す API で、文字列 prefix の commonprefix() とは違います。([Python documentation]2) また PurePath.is_relative_to() は純粋に文字列ベースであり、.. や symlink 解決をしない点に注意が必要です。([Python documentation]3)

    この Issue では、少なくとも次の方針を AC に入れるべきです。

    • repo root / cwd を基準に path を正規化する
    • absolute path は原則 reject
    • .. で Allowed Paths 外へ抜ける path は reject
    • missing file 自体は resolve(strict=True) できないため、存在する親ディレクトリを基準に containment を判定する
    • 最終判定は commonpath() 相当で行い、単純 prefix だけにしない

    推奨実装仕様

    #1328 は次のように仕様を硬くしたうえで実装開始するのが安全です。

    1. _extract_rg_path_operands(argv) を追加し、_rg_has_broad_search_path() と new_file_missing_expected 判定の両方から使う。既存 _candidate_new_allowed_path_target() は wrapper 化または削除する。

    2. rg exit 2 特例は専用 helper に閉じ込める。

    _classify_rg_exit2_missing_allowed_path(
      command,
      exit_code,
      stderr,
      cwd,
      allowed_paths,
      static_result
    ) -> Optional[classification_tuple]
    
    1. 戻り値 category は expected_baseline_fail に混ぜず、new_file_missing_expected にする。既存 category に混ぜると、後で「no-match」と「new-file missing」の監査区別ができません。

    2. compute_confidence() の high confidence set に new_file_missing_expected を追加する。追加しないと contract-review fragment の confidence が low になり、別 gate で不要な揺れを生みます。

    3. allowed_paths_review_gate.py の fingerprint fallback は触らない。これは 実装: issue-contract-review fingerprint refresh path を明示する #1329 の範囲であり、実装: issue-contract-review fingerprint refresh path を明示する #1329 も fingerprint 必須要件を維持し、欠落時は indeterminate のまま action-oriented reason を返す方針です。

    追加すべきテスト

    既存テストには subprocess 経由で preflight を実行する helper があり、JSON を parse する形になっています。 現在は rg exit 1 の expected fail や exit code contract のテストはありますが、rg exit 2 の new-file missing 特例はまだありません。

    最低限、以下を追加してください。

    優先度 ケース 期待
    P0 rg -n quoteUpgrade src/systems/UpgradeSystem.ts、path は Allowed Paths 内、未存在 expected_fail / new_file_missing_expected / go
    P0 missing path が Allowed Paths 外 expected_fail にならない
    P0 rg -n '(' src/systems/NewFile.ts invalid regex として human_judgment または blocked
    P0 rg --include '*.ts' foo src/systems/NewFile.ts static block、rg_option_mismatch
    P0 rg foo . broad_search_path_unbounded
    P0 rg -n -e quoteUpgrade --glob '*.ts' src/systems/UpgradeSystem.ts tests/upgrade-system.test.ts path operand 抽出が正しい
    P0 rg --regexp=quoteUpgrade -- src/systems/UpgradeSystem.ts -- 処理が正しい
    P0 rg -n -- -foo src/systems/UpgradeSystem.ts pattern が - 始まりでも path 誤判定しない
    P1 --max-count 1、--type ts、--replace x、--color never など value-taking options option value を path と誤認しない
    P1 test -f / test -d / test -s 既存分類 file_not_found_expected が回帰しない

    ripgrep は -e/--regexp で pattern を明示でき、pattern が - で始まる場合や複数 pattern の場合に使われます。また -- も同等の曖昧性回避に使われます。([Debian Manpages]1) -g/--glob は検索対象のファイルを glob で絞る option であり、path operand ではありません。([GitHub]4)

    #1328 本文への修正案

    現 Issue に追記するなら、次の4点です。

    1. classify_result() に allowed_paths が無い問題を明記
      classify_result() の signature 拡張、または main() 側 post-execution 判定への移動を AC に入れる。

    2. _candidate_new_allowed_path_target() は維持ではなく置換方針にする
      _rg_has_broad_search_path() 相当の argv parser を shared helper 化し、strict-mode の missing annotation 検出と rg exit2 分類の両方で使う。

    3. stderr 判定の blacklist を AC に入れる
      invalid regex / unsupported option / config error / permission denied / broad path / outside Allowed Paths は明示的に expected_fail 禁止。

    4. category と confidence の追加を AC に入れる
      new_file_missing_expected を fragment / confidence / schema consistency の対象として固定する。

    最終判断

    #1328 は 採用してよいが、そのまま実装プロンプトに渡すにはまだ危険 です。
    特に危険なのは「rg exit 2 を分類する」と言いながら、実際には classify_result() に Allowed Paths が渡っていない点と、既存 _candidate_new_allowed_path_target() が rg argv parser として未成熟な点です。

    実装者への指示は、次の一文に圧縮できます。

    rg exit 2 を expected fail にするのではなく、rg exit 2 のうち「static policy 通過済み・shared rg argv parser で抽出した missing path が全て normalized Allowed Paths 内・stderr が missing target 系のみ」と証明できるものだけを new_file_missing_expected として expected_fail/go に分類し、それ以外は従来通り fail-closed または human_judgment に残すこと。

  3. squne121 commented on Jul 4, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_triggered"
    
    "scope_signal_guard_reason_code:new_in_scope_area"
    
    "Issue 本文は Step 2 review 時点で verdict: approve だが、scope_signal_guard が新規 In Scope 領域追加を検知したため human 判断が必要"
    
  4. squne121 commented on Jul 4, 2026

    @squne121
    OwnerAuthor

    Human Decision: Scope Delta 承認(ANCHOR_SCOPE_REFRAME_V1)

    対象: issue-refinement-loop termination report の scope_signal_guard 判定。

    • scope_signal_guard_triggered: true
    • scope_signal_guard_reason_code: new_in_scope_area(## In Scope セクションへの新規機能領域追加を検知)
    • excluded_by_anchor_reframe: false(未承認のため human_escalation で停止していた)

    オーナー(squne121)として、上記 new_in_scope_area 判定が指摘した Issue 本文の ## In Scope 拡張(classify_result() への allowed_paths 引渡し・_candidate_new_allowed_path_target() の argv parser 置換・stderr whitelist/blacklist 判定を含む一連の拡張)を承認する。この拡張は Allowed Paths(下記 2 ファイル)の範囲内で完結しており、新しい Allowed Path 層の追加は伴わない。

    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1328
    decision: approve_scope_delta
    allowed_path_deltas:
      - ".claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py"
      - ".claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py"
    rationale: "scope_signal_guard の new_in_scope_area 判定(rg exit_code==2 の厳密分類ロジック追加・_candidate_new_allowed_path_target() の argv parser 置換・stderr whitelist/blacklist 追加を含む In Scope 拡張)を、既存 Allowed Paths の範囲内である前提でオーナーとして承認する。新規 Allowed Path 層の追加は発生しない。"
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  5. squne121 commented on Jul 4, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_resolved:new_in_scope_area (OWNER の ANCHOR_SCOPE_REFRAME_V1 承認により excluded_by_anchor_reframe=true / anchor_reframe_exclusion。https://github.com/squne121/loop-protocol/issues/1328#issuecomment-4882229920)"
    
    "review_issue_static_verdict:approve (check_issue_contract.py 0 blocking_issues)"
    
    "contract_review_environment_failure:vc_preflight_error timeout (run_contract_review_once.py --mode execute / --mode preflight-static とも status: runtime_error。baseline_vc_preflight.py の実行に180秒の固定タイムアウトがあり、AC8 の pnpm typecheck+lint+test+build と AC1/AC9/AC11 の重複 pytest 実行を合算すると180秒を超えるため、Issue 本文の内容とは無関係に安定して timeout する既知の環境/ツール制約)"
    
    "manual_verification_note:pnpm typecheck は単独実行で pass、対象テスト .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py は 112 passed / 1 skipped で pass。Issue 本文の VC は構造的に問題なし"
    
    "next_step_required:CONTRACT_REVIEW_RESULT_V1.status==go を確認できていないため approved 終了はできない。run_contract_review_once.py / contract_readiness_check.py / baseline_vc_preflight.py のタイムアウト値見直し(follow-up Issue 化)または timeout 制約のない環境での contract-review 再実行が必要"
    
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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions