Repository navigation
Closed
Labels
phase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "なし(単独改善)"
goal_ref: "既存ファイルへの ::新規テスト関数名 node-id を baseline_vc_preflight.py が canonical な expected_baseline_fail に誤分類しないよう、区別可能な非canonical category として分類できるようにする"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
なし(単独改善のため該当なし)
Current Validated Scope
なし(単独改善のため該当なし)
Remaining Parent Gaps
なし(単独改善のため該当なし)
Required Design References
- Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285(canonical VC shape: missing-file node-id を正とし、既存ファイルへの missing node-id を非canonical とする契約の確立元)
- .claude/skills/issue-contract-review/scripts/vc_baseline_shape_compiler.py(PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305 で追加された non-canonical → canonical rewrite compiler)
- .claude/skills/create-issue/references/body-authoring.md(canonical/非canonical VC shape の判定表)
- docs/dev/runtime-verification-policy.md
Runtime Verification Applicability
- VC Applicability:
immediate(具体的失敗コマンド・実環境検証が可能)- 根拠: baseline_vc_preflight.py の classify_result() は純粋関数的なユニットで、既存のテストファイルに直接テストケースを追加して即座に検証できる。
decision: immediate
applicable_acs:
- AC1
- AC2
- AC3
execution_environment:
cli_tools:
- python3
- uv
- pytest
auth_required: false
network_required: false
skip_conditions:
- "uv / pytest が利用できない実行環境では SKIP(exit 77)とし、fallback 経由の代替実行は行わない"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由での成功を PASS として扱わない。実際の pytest 実行結果のみを PASS/FAIL 判定に用いる"
artifact_requirements:
- "uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q の実行ログ"Outcome
baseline_vc_preflight.py の classify_result() / _is_regression_gate_command() を、既存ファイルへの ::新規テスト関数名 node-id(対象ファイルは存在するがテスト関数が未実装、baseline exit_code=4)を expected_baseline_fail / go にはしないまま、明確に区別可能な非canonical category(例: existing_file_missing_node_id_noncanonical のように、unknown / human_judgment とは別のカテゴリ名にして今後の diagnostics で識別できるようにする)として分類するよう変更する。ファイル自体が存在しない場合(真の missing-file node-id。missing_new_test_file.py::test_name のような Issue #1285 / PR #1305 の canonical 形を含む)の既存の expected_baseline_fail / go 分類は変更しない。
In Scope
baseline_vc_preflight.pyの_is_regression_gate_command()が pytest の positional path 引数を判定する際、::テスト名(pytest node id のサブパート)を含めた文字列全体でPath.exists()を呼んでいるため、既存ファイルに新規テスト関数を追加するケースで常にFalseを返し、結果としてclassify_result()の pytest exit_code=4 特殊分岐(file or directory not found→expected_baseline_fail/go)に到達できず、最終フォールバックのunknown/human_judgmentに落ちている現状の挙動を確認したうえで、この分岐先を「既存ファイルへの missing node-id」を明確に示す新設の非canonical category に変更する- 修正方針:
classify_result()/_is_regression_gate_command()で「対象ファイルは実在するが node id 全体としては存在しない」(pytest のERROR: not found: <path>::<name>/(no match in any of [<Module ...>])系メッセージ)ケースを検出した場合、expected_baseline_fail/goにはせず、unknown/human_judgmentとは別の新設 category(例:existing_file_missing_node_id_noncanonical)として分類する。これは Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 と PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305(.claude/skills/issue-contract-review/scripts/vc_baseline_shape_compiler.py)で確立された canonical VC shape 契約(既存ファイルへの missing node-id は非canonical、missing_new_test_file.py::test_nameのようなファイル自体が存在しない node-id が canonical)と整合させるための変更である - ファイル自体が存在しない場合(真の missing-file node-id、Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305 の canonical 形を含む)の既存の
expected_baseline_fail/go分類は変更しない - 修正対象の分類ロジックのみを変更し、
baseline-expectannotation の意味論やその他の分類パスは変更しない
Out of Scope
baseline-expect:annotation の仕様変更contract_review_result_parser.py/run_contract_review_once.py等、baseline_vc_preflight.pyを呼び出す上位スクリプトの変更- pytest exit_code=5(no tests collected)関連の既存分類ロジックの変更
.claude/skills/create-issue/references/body-authoring.md/.claude/skills/issue-contract-review/scripts/vc_baseline_shape_compiler.py/.claude/skills/edit-issue/scripts/issue_contract_hygiene_autofix.pyの変更(Allowed Paths 外)
Acceptance Criteria
- AC1: 既存ファイルへの
::新規テスト関数名node-id(対象ファイルは実在するがテスト関数は未実装、baseline で exit_code=4)をclassify_result()に渡した場合、expected_baseline_fail/goではなく、新設の非canonical category(unknown/human_judgmentとは異なる明示的なカテゴリ名)を返すことを検証する新規テストがtest_baseline_vc_preflight.pyに追加されている - AC2: ファイル自体が存在しない pytest コマンド(真の missing-file node-id。
missing_new_test_file.py::test_nameのような Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305 の canonical 形を含む)をclassify_result()に渡した場合、既存のexpected_baseline_fail/go分類が変わっていないことを検証する回帰テストが追加されている - AC3:
.claude/skills/issue-contract-review/scripts/tests/配下の pytest が全件 green である
Verification Commands
# AC1
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py::test_pytest_exit4_new_test_on_existing_file_is_noncanonical_category -q
# AC2
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py::test_pytest_exit4_missing_file_still_expected_baseline_fail -q
# AC3
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -qAllowed 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 の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
Required Skills
- Python(pytest / 正規表現ベースの分類ロジック実装)
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PRを原則とする- worktree で作業し、Draft PR として提出する
Notes for Reviewer
- 本 Issue は Issue 実装: agent delegation の AGY provider 固有分岐に対するテスト密度を引き上げる #1274(
実装: agent delegation の AGY provider 固有分岐に対するテスト密度を引き上げる)の impl-review-loop 実行中に発見された classifier ギャップの follow-up。実装: agent delegation の AGY provider 固有分岐に対するテスト密度を引き上げる #1274 ではbaseline_vc_preflight.pyの自動 VC preflight が AC1〜AC5 でhuman_judgmentを返したため、人間判断による override コメント(https://github.com/squne121/loop-protocol/issues/1274#issuecomment-4886908883)で impl-review-loop を続行した。なお 実装: agent delegation の AGY provider 固有分岐に対するテスト密度を引き上げる #1274 自体は PR test: AGY provider fixture 検証と empty-stdout warning 回帰テストを追加する #1345(MERGED)で別ルートで既に解消済み。 - 該当ロジック:
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.pyの_is_regression_gate_command()(test_path.exists()判定、656行目付近)とclassify_result()内の pytest exit_code=4 特殊分岐(2342行目・2472行目付近、re.search(r"error:\s+file or directory not found:", combined_lower))。 - 2026-07-07: OWNER の anchor comment(実装: baseline_vc_preflight.py が既存ファイル::新規テスト関数名 形式の pytest VC を expected_baseline_fail に分類できないバグを修正する #1347 (comment) 、REQUEST_CHANGES)を受け、Outcome / AC を修正した。Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 が「既存ファイルへの missing node-id」を禁止形(非canonical)、
missing_new_test_file.py::test_nameを canonical 推奨形として確立しており、PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305(MERGED)でvc_baseline_shape_compiler.pyが既に non-canonical → canonical への rewrite を実装済みであることが codebase-investigator の調査で確認された。当初の Outcome/AC(既存ファイルへの missing node-id をexpected_baseline_fail/goに分類させる)はこの canonical VC shape 契約と矛盾していたため、逆方向(expected_baseline_fail/goにはせず、区別可能な非canonical category として分類する)に修正した。あわせて、ファイル自体が存在しない場合の既存のexpected_baseline_fail/go分類は現行実装通りであり変更対象ではないことを AC2 として明示した。 ## Allowed Pathsは今回の修正で変更していない(baseline_vc_preflight.pyとそのテストファイルの2ファイルのまま)。anchor comment にANCHOR_SCOPE_REFRAME_V1payload が付与されておらず(scope_delta_decision.status: fail_closed、allowed_path_deltas: [])、Allowed Paths 拡張の根拠がないため。
Metadata
Metadata
Assignees
Labels
phase/implementationImplementation phase
Activity
squne121 commentedon Jul 7, 2026
判定: REQUEST_CHANGES
#1347 の現象自体は実在します。ただし、Issue本文のまま実装すると、過去に確立した「pytest baseline-fail VC の canonical form」契約と衝突します。現状のまま
expected_baseline_fail / goに寄せるのは危険です。確認対象は #1347 本文・コメント、発見元の #1274 / PR #1345、既存の #1285 / PR #1305、#1328 / PR #1340、
baseline_vc_preflight.py、vc_baseline_shape_compiler.py、body-authoring.md、pytest / pathlib 公式仕様です。#1347 のコメントは空でした。まず事実関係
pytest 公式仕様では、
tests/test_mod.py::test_funcのように::で module / class / function を指定する collection argument が正規の指定方法です。また exit code 4 は “command line usage error”、exit code 5 は “no tests were collected” です。([pytest]1) ([pytest]2)一方、現在の
_is_regression_gate_command()は pytest の positional arg をそのままPath(arg).exists()に渡しています。つまりexisting_test_file.py::test_missingはファイルパスではなく node-id 付き文字列なので、実ファイルexisting_test_file.pyが存在してもexists()は false になります。 Python のPath.exists()は「その path が既存ファイル/ディレクトリを指す場合だけ True」であり、無効・アクセス不能・欠落なら False です。([Python documentation]3)さらに
classify_result()側の pytest exit 4 特例は、error:\s+file or directory not found:に一致する場合だけexpected_baseline_fail / goにします。既存ファイル上の missing node-id は pytest 的にはERROR: not found: <file>::<name>/no match in ...系であり、この regex には入りません。ここまでは #1347 の問題設定どおりです。
致命的な問題 1: #1285 / #1305 の canonical 契約と衝突している
#1347 は「既存ファイルに
::新規テスト関数名を付けた pytest VC をexpected_baseline_fail / goにしたい」というIssueです。ところが、#1285 はまさにこの形を禁止形として扱い、missing_new_test_file.py::test_nameへ rewrite する compiler を追加するためのIssueでした。#1285本文では、既存ファイルへの missing node-id は「判定不能」であり、baseline_vc_preflight.pyの exit code 契約は変更しない、と明記されています。PR #1305 も同じ立場で、
existing_test_file.py::test_missing_nameを canonical missing-file node-id へ rewrite するvc_baseline_shape_compiler.pyを追加し、baseline_vc_preflight.pyの pytest exit code 契約は変更しない、と説明しています。現行ドキュメント
body-authoring.mdでも、pytest baseline-fail VC は「まだ存在しないテストファイルへの node-id」で書く、既存ファイルへの missing node-id は禁止形、と明記されています。したがって #1347 は、単なる classifier bugfix ではなく、既存のVC設計思想を戻す変更です。実装するなら
baseline_vc_preflight.pyとテストだけでは足りず、少なくとも次も同時に変更対象です。.claude/skills/create-issue/references/body-authoring.md.claude/skills/issue-contract-review/scripts/vc_baseline_shape_compiler.py.claude/skills/edit-issue/scripts/issue_contract_hygiene_autofix.py現Issueの Allowed Paths はこの影響範囲を許可していません。よって、現契約のままなら #1347 は scope insufficient です。
致命的な問題 2: AC2 が現行実装・既存契約と逆
#1347 の AC2 は「ファイル自体が存在しない pytest コマンドは既存の unknown / human_judgment 系挙動が変わらないこと」を要求しています。
これは現行実装と矛盾します。
classify_result()には、pytest exit 4 かつfile or directory not foundならexpected_baseline_fail / goを返す分岐が regression gate 判定外にも存在します。また #1285 の canonical form は「missing file node-id」です。つまり、ファイル自体が存在しない
missing_new_test_file.py::test_nameを expected baseline fail にすることが既存方針です。よって AC2 はそのままでは不正です。正しくは以下のどちらかです。
missing_new_test_file.py::test_nameはexpected_baseline_fail / goのまま維持する。既存ファイル missing node-id は compiler/autofix 側で canonical form に直す。致命的な問題 3: 発見元 #1274 はすでに別ルートで解消済み
#1347 は #1274 の impl-review-loop で発見された gap を発端にしていますが、#1274 自体は PR #1345 で解消済みです。PR #1345 は #1274 の Contract Repair Note に従い、
_validate_agy_request()への読み替え、fixture補完、AGY provider テスト追加で close しています。つまり #1347 は「#1274 を進めるための緊急 blocker」ではなく、今は VC canonicalization / preflight classifier の設計判断として扱うべきです。
推奨判断
現時点の推奨は #1347 をそのまま実装しない です。
より安全な修正方針は、
baseline_vc_preflight.pyに既存ファイル missing node-id をexpected_baseline_failとして追加することではなく、次のどちらかです。推奨A: #1347 を「非canonical VC を body-author-fixable にする」Issueへ書き換える
既存ファイルへの missing node-id を見つけたら、
expected_fail / goではなく、pytest_missing_node_id_on_existing_file_noncanonicalのようなblockedまたはneeds_fix系カテゴリにして、vc_baseline_shape_compiler.pyの rewrite hint へ誘導する。これは #1285 / #1305 / body-authoring と整合します。この場合の実装対象は classifier 本体より、readiness / hygiene autofix の連携強化です。
代替B: どうしても expected_baseline_fail にするなら契約変更Issueとして起票し直す
この場合は #1347 の Allowed Paths を拡張し、以下を明示する必要があります。
body-authoring.mdの canonical table を更新するvc_baseline_shape_compiler.pyの rewrite 方針を変更するissue_contract_hygiene_autofix.pyの fail-closed 条件を見直すbaseline_vc_preflight.pyの pytest exit 4 判定をfile not foundとnode-id not foundで明確に分離する実装上は
_is_regression_gate_command()でarg.split("::", 1)[0]を path 判定に使うだけでは不十分です。classify_result()側でも、ERROR: not found:かつ(no match in any of [<Module ...>])のような missing node-id 系 stderr を識別し、既存ファイルが存在する場合だけ分類する必要があります。単に exit code 4 を広くexpected_baseline_failにすると、pytest の usage error 全般を false-green にします。pytest公式上、exit code 4 は広い「command line usage error」だからです。(pytest)#1347 本文に対する修正案
現契約を維持するなら、#1347 はこう直すのが安全です。
現Issue本文のまま進めるなら、私は REQUEST_CHANGES。問題の観測は正しいですが、解決策が既存の canonical VC 設計を破壊します。
squne121 commentedon Jul 7, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 7, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 7, 2026
Contract Review — Human Override(issue-contract-review が human_judgment を返したための人間判断)
注記: この YAML は
issue-contract-reviewが生成したCONTRACT_REVIEW_RESULT_V1ではありません。baseline_vc_preflight.pyによる自動 VC preflight の実行結果は AC1/AC2 についてhuman_judgmentでした。以下の理由分析に基づき、人間(squne121)がimpl-review-loopの続行を承認したことを記録するコメントです。Human Override 理由
baseline_vc_preflight.pyを用いた VC preflight を実行した結果、AC1/AC2 の VC コマンド(uv run pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py::test_pytest_exit4_new_test_on_existing_file_is_noncanonical_category -qおよび同::test_pytest_exit4_missing_file_still_expected_baseline_fail -q)がhuman_judgmentに分類された。原因を調査した結果、Issue 本文側の問題ではなく preflight classifier の既知のギャップ であることを確認した。uv run pytest <既存ファイル>::<新規テスト関数名> -q形式。対象ファイル(test_baseline_vc_preflight.py)は既存だが、参照しているテスト関数(test_pytest_exit4_new_test_on_existing_file_is_noncanonical_category/test_pytest_exit4_missing_file_still_expected_baseline_fail)はまだ実装されていないため、baseline 実行でexit_code=4(pytest "not found" / no tests ran)になる。これは新規テスト追加 Issue における想定通りの baseline 失敗であり、docs/dev/runtime-verification-policy.mdの意図に沿うexpected_baseline_fail相当のケースである。baseline_vc_preflight.pyの_is_regression_gate_command()(test_path.exists()判定、656行目付近)は pytest の positional path 引数をPath(cwd) / argとして::テスト名を含めた文字列のまま.exists()判定するため、常にFalseを返す(::付き文字列がファイルシステム上に実在することはあり得ない)。そのためclassify_result()内の pytest exit_code=4 のfile or directory not found特殊分岐(2342行目・2472行目付近)に到達せず、最終フォールバックのunknown/human_judgmentに落ちる。重要な自己言及性(bootstrap gap)について: この preflight classifier のギャップは、まさに Issue #1347 自身が修正しようとしているバグそのものである。Issue #1274 のときは同種のギャップに対する classifier 修正を別 Issue(本 #1347)として起票する方針を取ったが、今回は #1347 自身が「既存ファイルに
::新規テスト関数名形式で追加される pytest VC をexpected_baseline_fail相当ではなく正しい非canonical category として分類できるようにする」修正を Outcome / AC に持つ Issue であるため、追加の follow-up Issue を新たに起票する必要はない。#1347 の実装が完了し merge されれば、この bootstrap gap 自体が解消される。人間判断により、上記 AC1/AC2 を
expected_baseline_fail相当(新規実装前の baseline 失敗)としてgoと判定し、impl-review-loopを継続する。AC3(
preflight-scope: runtime_only、.claude/skills/issue-contract-review/scripts/tests/配下 pytest 全件 green)は preflight 側でskipped/go(runtime_verification_required: true)であり、実装後の runtime 検証で担保する。fix: PR #1366 レビュー指摘を修正 (readiness mapping / regex 厳格化 / 実 pytest 統合テスト)
feat: baseline_vc_preflight に baseline-expect:fail escape hatch を追加する (…