Skip to content

feat(#366): add pytest invocation detection and exit 4/5 baseline-fail classification - #372

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-366-pytest-classifier
May 24, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-366-pytest-classifier

Conversation

@squne121

@squne121 squne121 commented May 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #366

Summary

  • Add pytest invocation detection using argv/token parsing with shlex.split()
  • Implement _is_pytest_invocation() to recognize pytest, python -m pytest, uv run pytest, etc.
  • Implement _strip_uv_run_options() to unwrap uv run flags (--locked, --with, etc.)
  • Extend classify_result() to recognize pytest exit 4 + file not found and exit 5 + no tests collected as expected_baseline_fail / go
  • Add 10 new test functions covering AC1-AC7 (detection, exit codes, negative cases, regressions)
  • Add 5 fixture files for pytest test scenarios

Test Plan

  • All 53 baseline_vc_preflight.py tests pass (39 existing + 10 new AC tests + 4 other existing tests)
  • pytest -k pytest_invocation_detect_* (4 functions covering pytest / python -m pytest / uv run / non-pytest patterns)
  • pytest -k pytest_exit4_missing_file_expected_fail (AC2)
  • pytest -k pytest_exit5_no_tests_collected_expected_fail (AC3)
  • pytest -k pytest_exit4_usage_error_not_expected (AC4 negative test)
  • pytest -k non_pytest_exit4_not_expected (AC5 negative test)
  • pytest -k pytest_unexpected_pass_unchanged (AC6 regression)
  • pytest -k full_preflight_pytest_baseline_fail_status_pass (AC7 full preflight)
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes
  • pnpm build passes

Allowed Paths Compliance

Changes confined to allowed paths:

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py ✓
  • .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py ✓
  • .claude/skills/issue-contract-review/scripts/tests/fixtures/*.md (new pytest fixture files) ✓

Generated with Claude Code

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST_CHANGES

self-authored PR のため --comment で verdict を記録(GitHub 制約)。

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=CLEAN
  • head_sha=86fcf7ff113de1d9daaa4c71b359adf0e3b3a710(PR と worktree HEAD 一致 / G4 PASS)

G1-G5 Deep Verification

Gate 結果 証跡
G1: CI test path coverage FAIL .github/workflows/ci.yml:90-94 の python-test job は 5 固定パス(gemini-cli-headless-delegation/, edit-issue/, create-issue/tests/, create-issue/scripts/tests/, ssot-discovery/, hooks/)のみ実行し、本 PR の新規 AC1-AC8 テスト(.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py)は CI で 1 度も実行されていない。`gh run view 26359166065 --log --job 77591402129
G2: implementer self-claim verification partial PR 本文 "53 passed" は local 実行のみ。reviewer 環境 (uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/ -q → 53 passed, 1 skipped in 3.62s) で独立再現したが、CI 証跡ではない。
G3: anchor oracle 実装の存在 PASS baseline_vc_preflight.py:178-179, 245, 279, 295, 304, 385 で shlex.split / _strip_uv_run_options / _is_pytest_invocation 全て確認。anchor B1 の exit 4 vs exit 5 分離は baseline_vc_preflight.py:388 (exit_code == 4 and re.search(r"error:\s+file or directory not found:", ...)) と baseline_vc_preflight.py:392 (exit_code == 5 and ("no tests ran" or "no tests collected" or "collected 0 items")) で正しく分岐。新カテゴリ追加なし(expected_baseline_fail 再利用)も確認。
G4: head SHA consistency PASS gh pr view 372 --json headRefOid = git -C worktree rev-parse HEAD = 86fcf7ff113de1d9daaa4c71b359adf0e3b3a710。
G5: fixture が validator 意図 path に到達 PASS(local 再現) fixture 5 件(pytest_exit4_missing_file.md / pytest_exit5_no_tests.md / pytest_usage_error.md / bash_exit4_file_not_found.md / pytest_baseline_only.md)はすべて run_preflight を経由し、test assert は classification == expected_fail, category == expected_baseline_fail, decision == go を実体検査。AC marker 欠落による loophole 通過ではない。anchor B4(git stash → fixture 化)解消も確認。

Evidence Check

項目 結果 根拠
AC coverage △ AC1-AC8 を ## Test Plan の [x] pytest -k <name> で網羅。SKILL template 標準 ## 受け入れ条件の達成状況 セクション名は不採用だが機能的に同等。
Allowed Paths ○ 7 変更ファイル全てが contract ## Allowed Paths (baseline_vc_preflight.py / tests/test_baseline_vc_preflight.py / tests/fixtures/) 配下。逸脱なし。
CI Verification × 5 jobs 全 PASS だが python-test job は新規テストを 実行していない。本 PR の AC1-AC8 に対する CI 証跡が 0。
検証コマンド結果(PR 本文) △ ## Test Plan に [x] 記録あり。standalone section ## 検証コマンド結果 は未採用。
scope 混入 なし diff 7 ファイル全て scope 内。
Closes #366 keyword 欠落 PR 本文に Closes #N / Fixes #N / Resolves #N のいずれも存在しない(タイトル feat(#366): のみ)。SKILL Step 1 Stop Condition 抵触。
Schema / Safety 適用性 not_schema_change / not safety-sensitive classifier 内部ロジック追加のみ。consumer 境界変更なし。docs/dev/runtime-verification-policy.md 変更なし、permission/sandbox/transport 影響なし。両 Gate skip。
Runtime VC not_applicable contract runtime_verification_applicability.decision: not_applicable。証跡要件なし。

Local independent verification (reviewer)

$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/ -q
53 passed, 1 skipped in 3.62s

実装品質自体は AC1-AC8 を満たすことを reviewer 環境で確認済み。ただし CI で実行されないことが本 PR の blocker。

Blockers

  1. CI coverage gap (G1): 新規 AC1-AC8 テストが .github/workflows/ci.yml の python-test job に含まれていない。本 PR が修正対象とする baseline_vc_preflight.py の挙動を CI が永続検証できないため、将来の regression を CI で防げない。
    • fix_delta: .github/workflows/ci.yml:94 の直後に - run: uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/ を追加し、本 PR に含める(Allowed Paths 拡張も必要; 追加 path: .github/workflows/ci.yml)。または follow-up Issue を mandatory_follow_up として明示し本 PR にリンク。
  2. Closes #366 欠落: SKILL Step 1 / Stop Conditions に従い PR 本文に Closes #366 を追加する必要がある。
    • fix_delta: PR 本文 ## Summary の直前または末尾に Closes #366 を追記。

Non-blockers(任意改善)

  1. PR 本文セクション名を template 標準(## 受け入れ条件の達成状況 / ## 検証コマンド結果 / ## Allowed Paths 遵守)に揃えると LOOP_PROTOCOL parser との親和性が高まる。

LOOP_VERDICT

verdict: REQUEST_CHANGES
blockers:
  - id: ci-coverage-gap
    severity: blocker
    summary: "新規 AC1-AC8 テストが .github/workflows/ci.yml の python-test job で実行されていない(G1 fail)"
    code_ref: ".github/workflows/ci.yml:90-94"
    ci_run_ref: "https://github.com/squne121/loop-protocol/actions/runs/26359166065/job/77591402129"
    fix_delta: ".github/workflows/ci.yml に `uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/` を追加する。Allowed Paths も合わせて拡張するか、follow-up Issue として materialize する。"
  - id: closes-keyword-missing
    severity: blocker
    summary: "PR 本文に Closes #366 / Fixes #366 / Resolves #366 のいずれも存在せず、SKILL Stop Condition 抵触"
    code_ref: "PR #372 body"
    fix_delta: "PR 本文に `Closes #366` を追記する。"
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 86fcf7ff113de1d9daaa4c71b359adf0e3b3a710
follow_up_issue_requests:
  - title: "ci.yml の python-test job に baseline_vc_preflight tests を追加する"
    issue_kind: implementation
    severity: mandatory_follow_up
    source:
      kind: pr_review
      url: "https://github.com/squne121/loop-protocol/pull/372"
      note_id: "1"
    dedupe_key: "follow-up:squne121/loop-protocol:pr-372:ci-coverage-baseline-vc-preflight"
    desired_destination: ".github/workflows/ci.yml の python-test job が .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py を実行し、AC1-AC8 の regression を CI で防止する状態"
    validated_scope_delta: ".github/workflows/ci.yml に `uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/` を追加。必要に応じて #366 contract の Allowed Paths を拡張するか、ci-config 単独 PR として扱う。"
    origin_skill: pr-review-judge
    labels:
      - triage-required
      - kind/implementation
      - phase/implementation

squne121 and others added 2 commits May 24, 2026 19:57
…l classification

- Add _is_pytest_invocation() helper to detect pytest via argv parsing
- Add _strip_uv_run_options() to unwrap uv run flags
- Extend classify_result() with AC2/AC3: pytest exit 4 + file not found / exit 5 + no tests
- Add 10 new test functions for AC1-AC7 (pytest detection, exit codes, regressions)
- Add 5 fixture files for pytest test scenarios
- All 53 baseline_vc_preflight tests pass + existing tests regression-free

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…on-test job

Add missing pytest invocation step to merge gate that runs new test functions
for pytest invocation detection and exit 4/5 baseline-fail classification.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@squne121
squne121 force-pushed the worktree-issue-366-pytest-classifier branch from 9bd2a67 to 4a29393 Compare May 24, 2026 10:57

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=CLEAN
  • PR head 4a29393 == CI run 26359364169 head_sha (rebase onto main 確認済)

Evidence Check (iter 2 re-review)

B1 ci-coverage-gap (iter 1 blocker) — RESOLVED

B2 closes-keyword-missing (iter 1 blocker) — RESOLVED

  • PR body 冒頭に Closes #366 確認済(gh pr view 372 --json body で直接抽出)

G3 anchor oracles 保持確認

  • shlex.split (line 179): 保持
  • _strip_uv_run_options (line 245): 保持
  • _is_pytest_invocation (line 279): 保持
  • exit 4 → expected_baseline_fail (line 388-390): 保持
  • exit 5 → expected_baseline_fail (line 392-398): 保持
  • 新カテゴリ追加なし(既存 expected_baseline_fail を再利用、In Scope 通り)

G5 fixture coverage

  • 5 fixtures 存在: bash_exit4_file_not_found.md, pytest_baseline_only.md, pytest_exit4_missing_file.md, pytest_exit5_no_tests.md, pytest_usage_error.md
  • test_baseline_vc_preflight.py に AC1-AC7 関連の 10 test function 参照を確認(AC1 detection 4本 + AC2-AC7 各分岐)

AC coverage: AC1-AC8 すべて PR body Test Plan で [x] + 検証コマンド結果記述あり (issue contract の Verification Commands 8 件と 1:1 対応)

Allowed Paths: 遵守。diff 8 ファイルすべて amend 後 Allowed Paths (baseline_vc_preflight.py / tests/test_baseline_vc_preflight.py / tests/fixtures/ / .github/workflows/ci.yml) 内

CI Verification: 5 jobs (build/lint/python-test/test/typecheck) 全 PASS @ run 26359364169

Safety / Security: shlex.split のみで shell 実行なし、secret 露出なし、scope 混入なし

Schema/Safety Gate: 該当なし(classifier ロジック追加のみ・consumer 境界変更なし・safety boundary 該当なし)。Runtime Verification decision: not_applicable (issue contract に明示) — 整合

Blockers

  • なし

Non-blockers(任意改善)

  • なし

LOOP_VERDICT

verdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 4a293935ebf80bb82843b033762f82159325f964
follow_up_issue_requests: []

@squne121
squne121 marked this pull request as ready for review May 24, 2026 11:16
@squne121
squne121 merged commit f078bc4 into main May 24, 2026
5 checks passed
@squne121
squne121 deleted the worktree-issue-366-pytest-classifier branch May 24, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

改善: baseline_vc_preflight.py classifier に pytest invocation 検出と exit 4/5 baseline-fail 分類を追加する

1 participant