Repository navigation
fix: Step 2 canary が広域 pytest collection を exit 77 で中断しないようにする - #2909
Conversation
非 opt-in の serial 広域 collection で canary が pytest.exit(77) し、他の test nodes ごと session を終了していた。pytest 解決済み target (config.args) から「明示単独 runtime」を判定し、 単独時のみ capsys.disabled() 内の行頭 SKIP: stdout と exit 77、それ以外は item skip にする。 gh auth status の OSError / TimeoutExpired だけを producer 起動前の unavailable として扱う。 hermetic な子 pytest(実 canary module、test-double、実 -n 2 xdist)の focused regression を追加。 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Preview URLPreview removed (PR #2909 closed). |
pr-reviewer 判定: APPROVE(iteration 0)
verdict: APPROVE
reviewed_head_sha: "aeac8c8c87812d6c91ae6001bff87399e872e5c0"
blockers: []
warnings:
- "mutation gap: gh auth status 境界の broad except Exception をテストが検出できない(実装自体は正しい)"
- "env 漏れ検証の control 側 assertion が弱い(isolation 側の assertion は有効)"
- "ローカル AC5 の 3 件は uv_version_mismatch 由来の既存失敗。CI では 0 failure" |
判定:REQUEST_CHANGES — 修正方針は妥当ですが、小さな契約違反が2点残っています広域 pytest を止めないという主目的には、適切な方向の修正です。ただし、単独実行の判定と レビュー対象は head 検証範囲について先に明記します。こちらでは PR の判定・出力 helper の処理を変更せず抜き出した隔離再現を Python 3.13.5 / pytest 9.0.2 で実行しました。リポジトリ全体の locked テスト、実 xdist、live producer は実行していません。一方、リポジトリが使用する pytest 9.0.3 の公式実装も取得し、今回の論点に関係する引数解決と出力処理を照合しています。 1. P2 — |
| 呼び出し | 現実装の結果 | 小修正後 |
|---|---|---|
明示ファイル+-q |
77、行頭 SKIP: あり |
同じ |
| 明示ファイル、通常表示 | 77、行頭 SKIP: なし |
77、行頭あり |
明示ファイル+-v |
77、行頭 SKIP: なし |
77、行頭あり |
明示ファイル+-q -v |
77、行頭 SKIP: なし |
77、行頭あり |
target なし、testpaths が canary 1件 |
77 | 0、item skip |
directory+-k ac9 -q |
0、item skip | 同じ |
reproduce_boundaries.py隔離再現スクリプトとreproduction-results.json実行結果の JSONを添付します。これらは不具合の切り分け用であり、リポジトリに追加する正式な回帰テストは、現 PR と同様に実際の canary module を対象にしてください。
非ブロッカー:認証境界の mutation gap は、1ケースで補強できる
既存レビューが挙げている **「except Exception に広げる mutation が生き残る」**点は、そのとおりです。test-double の認証確認側には timeout、OSError、非ゼロ終了がありますが、それ以外の例外を投げるモードがありません。一方、現在の canary 実装自体は (OSError, subprocess.TimeoutExpired) に限定しているため、現時点の実装不具合として格上げする必要はありません。
補強するなら、認証確認の test-double で RuntimeError を投げる1ケースを追加し、exit 1、canary が failed、行頭 SKIP: なし、producer 未起動を確認するだけで十分です。大きな mutation framework や例外型の総当たりは勧めません。
環境分離テストの control 側も returncode != 77 だけなので、意図した plugin import failure などまで確認すると説明力が上がります。ただし、これも今回の2件と違い、現在の実装が壊れているという指摘ではありません。
関連 Issue・PR を踏まえ、今回広げない方がよい範囲
#2860 の独立した失敗は、今回の修正と切り離すべきです。 発見元のコメントは、canary による session 中断と、先行する3件の uv_version_mismatch を別問題として記録しています。今回の実装報告でも broad run は最後まで走り、3件の既存 failure を隠さず報告しています。この扱いは維持してよいです。
PIPE → wait() → communicate() の問題を、この PR の必須修正に混ぜる必要もありません。 Python 公式文書が警告する待機パターンですが、既に #2907 が専有し、#2903 のマージ後に同ファイルを修正する依存関係まで定義されています。重複起票や並行修正は、むしろ作業を増やします。[Python documentation](https://docs.python.org/3/library/subprocess.html)
live producer や Claude Code の background+join の再実地検証も、今回の完了条件へ追加しない方がよいです。 導入 PR #2622 は、pytest 内の producer smoke と実際の Claude Code 実行境界を明確に分離しています。今回扱う collection・exit code・stdout は、外部サービス不要の子 pytest で検証するのが適切です。
推奨する着地点は、2ファイルのスコープを維持したまま、args_source の確認と改行を追加し、その境界ケースを既存 contract test へ載せることです。 そのうえで locked 環境の focused regression と既存 CI を再実行すればよく、全 pytest の exit 77 を成功扱いする変更、canary の一律除外、新たな承認・証跡ハーネスは不要です。
|
live state と current また前回は そのまま対話的 Claude Code に貼れる prompt です。 repo は 対象は PR #2909、特に OWNER の top-level PR conversation comment ID 5975502310 です。source Issue は #2903 です。 あなたは既に auto mode で起動済みの対話的 Claude Code session です。現在の session を継続してください。ただし、過去 session の state、保存済み artifact、過去の APPROVE、過去に観測した SHA、CI 結果を current authority として再利用せず、最初に live repository / GitHub state を fresh に取得してください。 目的は current repository の
相当を出せる、人間が merge 判断できる直前まで完遂することです。 merge / auto-merge / Issue close / post-merge cleanup は行わないでください。 この invocation における人間判断comment 5975502310 自体は OWNER の したがって、この invocation では comment 5975502310 が comment 5975502310 を 今回処理すべき trusted human review / fix_delta の authority として読み、そこに書かれた具体的 defect を修正してください。 ただし、作業開始後に より新しい OWNER コメントで明示的に「停止」「変更しないでください」等が投稿されている場合は、その fresh comment を current human veto として扱ってください。 明示的な承認この invocation について、repository-native workflow が必要とする通常の非破壊作業を明示的に承認します。iteration ごとの追加承認は不要です。 承認対象:
を承認します。 これは Claude Code permission bypass の承認ではありません。現在の auto mode を維持してください。 以下は禁止します。
0. 最初に live state と current repository contract を読む最初に fresh に最低限以下を確認してください。 GitHub
current HEAD の repository contract最低限:
を読んでください。 必要なら installed locked pytest の API と official pytest 9.0.x docs を照合してください。特に:
の current semantics は推測しないでください。 この prompt に書かれた過去 SHA は authority にしません。fresh live value を使ってください。 1. Root-Owned Entry Transition / Landing Disposition を fresh に実行source Issue #2903 に対して current canonical Root-Owned Synchronous Entry Transition と intake / landing disposition を実行してください。 comment 5975502310 は今回 user が明示選択した human review context です。current context protocol が human-context comment URL / ID の binding を要求する場合は正規に渡してください。 PR #2909 が current exact linked open/draft candidate であることが確認できた場合は、canonical producer が返す
等の 実際の current result をそのまま consume してください。 既存 PR / branch / worktree があるのに、新しい worker branch や duplicate PR を作らないでください。 既存 worktree が dirty / foreign ownership の場合は勝手に clean/reset/remove せず、current canonical recovery procedure に従ってください。 2. comment 5975502310 の mandatory fix_deltacomment の 2 件は今回の blocker です。 Blocker A —
|
…2903) - 単独 runtime の SKIP 出力を改行始まりにし、-q 有無・通常・-v・-vv の全てで stdout の行頭 SKIP: と exit 77 を維持する - config.args_source が ARGS 以外 (testpaths / invocation dir) の場合は 単独 runtime と見なさず item skip にする - 回帰テストを追加: verbosity 別の行頭 SKIP、testpaths 由来 canary の item skip、 gh auth status の想定外例外が SKIP/77 に変換されないこと Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Summary
pytest.exit(returncode=77)を呼び、他の test nodes ごと session を終了していた問題を修正しました。config.args)から判定します。serial かつ解決済み target が canary ファイル 1 つ、またはその exact node-id だけの「明示単独 runtime」で unavailable のときだけ、capsys.disabled()内で行頭SKIP:を stdout に出して exit 77 にします。-kで結果的に 1 件になった実行・target 引数なし・xdist worker では、canary item だけをpytest.skip()にし、session は継続して独立した failure を隠しません。item skip の経路は追加の stdout を出しません。gh auth statusのOSError/subprocess.TimeoutExpiredだけを producer 起動前の unavailable として扱います(明示的な型のみで、広いexcept Exceptionは使いません)。producer 起動後の失敗は従来どおり FAIL です。test_step2_canary_collection_contract.pyで、実際の canary module を対象に hermetic な子 pytest をsys.executable -m pytestで起動し、exit code・stdout の行頭SKIP:・node 単位の outcome(junit xml)・実-n 2の xdist を検証します。PIPE→wait(timeout)→communicate()の順序(別 Issue 実装: opt-in Step 2 canary live path の pipe 待機順序による潜在 deadlock を解消する #2907 の責務のため変更していません)、baseline_vc_preflight.py/ conftest / pytest 設定、実装: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped temporary workspace で解消する #2860 の uv fixture 起因の failures。受け入れ条件の達成状況
-kで 1 件だけ残った実行・target 引数なしで、canary item のみ skip し session は exit 77 にならず、無関係な failing node は FAIL のまま exit 1、独立 failure が無ければ exit 0 になることを子 pytest で確認しました。-k/-m付き、exact node-id、相対 path と symlink 経由)の unavailable でchild.returncode == 77かつchild.stdoutの行頭にSKIP:が出ることを、stdout の行単位で assert しています。gh auth statusの timeout / OSError も同じ結果で、producer 起動後のRuntimeError/TimeoutExpiredは SKIP に変換されず FAIL(exit 1)です。親 regression は子が SKIP を正しく表現したことを検証して PASS しますが、live producer の PASS ではありません。LOOP_CANARY_STEP2_LIVE_ENABLEが未設定・0・空・不正値では producer 起動境界(subprocess.Popen)にもgh auth statusにも到達せず、1のときだけ認証確認の後にrun_root_review_pipeline.py produceを含む argv で起動境界へ進むことを、子 process 内の test-double で観測しました(実 network なし)。--collect-onlyは opt-in1でも body を実行しません。-n 2の xdist で、canary は item skip、独立 failure は可視、後続 node は実行され、INTERNALERROR/ crash がないことを junit xml と-rAで確認しました。検証コマンド結果
fix_delta(OWNER レビュー対応)の検証結果: 単独 runtime の
SKIP:行は-q有無・通常・-v・-vvのすべてで stdout の行頭に出て exit 77 を維持します(canary 単体の直接実行でも 4 通りとも exit 77・行頭SKIP:1 行を確認)。config.args_sourceがArgsSource.ARGS以外(testpaths/ invocation dir)の場合は単独 runtime と見なさず item skip になります。gh auth statusの想定外例外(RuntimeError)は SKIP/77 に変換されず exit 1 のまま、producer 起動境界にも到達しないことを 1 case で固定しました。本 PR は #2860 の PASS を主張しません。上記 3 failed は #2860 側の uv fixture 起因の独立した failure です。
Allowed Paths 遵守
.claude/skills/issue-refinement-loop/tests/test_step2_execution_surface_canary.py.claude/skills/issue-refinement-loop/tests/test_step2_canary_collection_contract.py(新規)baseline_vc_preflight.py/ pytest 設定 /python-test-plan.jsonは変更していません。新規 file は既存の登録済み directory 配下です)Checks
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_step2_canary_collection_contract.py -q(35 passed)uv run --locked pytest .claude/skills/create-issue/tests/ .claude/skills/issue-refinement-loop/tests/ -q(上記のとおり、既存の 3 failed を除いて PASS)uv run --locked ruff check .claude/skills .claude/scripts scripts schemaspnpmの 4 コマンドは対象外です)Schema Change Applicability
Schema Consumer Inventory
N/A
reason: schema_change ではなく、既存 consumer の before/after 差分も発生しません。
Safety Claim Matrix
gh auth statusの OSError / TimeoutExpired 以外を SKIP に変換しない-k/ 引数なし / 実-n 2で独立 failure が FAIL のまま残るNotes
config.argsの resolved path 比較です。testscollected、failure 件数、raw command の部分一致、config.invocation_params.argsは使っていません。PYTEST_*/LOOP_CANARY_*を継承させず、plugin autoload を無効化しています。親に opt-in / worker 変数が残っていても子の挙動が変わらないことを 1 case で検証し、継承した場合に挙動が変わる control も含めています。🤖 Generated with Claude Code