fix: gh が使えないとき運用レポートは劣化して出力される (#420) - #422
Merged
Merged
Conversation
任意の enrichment source である gh CLI が未導入の環境で、 FileNotFoundError が未捕捉のまま伝播していた。これは subprocess.run の 戻り値ではなく呼び出し自体が送出するため、周囲の except ValueError は 最初から到達できなかった。 より危険だったのは捕捉後である。取得失敗で issues が空になり、 open_issues が 0 件として扱われ、overall_state が freeze-ready に 到達し得た。外部照会が落ちたことを理由に、レポートが最も強い判定に 昇格する経路であり、証拠の不在が証拠として読まれていた。 - gh の失敗を GitHubUnavailable に一本化し、理由を機械可読な語彙に分ける (未導入/実行不可/timeout/認証/rate limit/一般失敗/解析不能)。 操作者の次の行動が異なるため、畳まない。 - 未取得の件数は 0 ではなく None とし、描画は unknown と出す。 0 と「わからなかった」が同一に描画された時点で読み手に戻る道はない。 - freeze-ready は availability == available を要求する。 - ok は必須のローカル検査の成否を表す。任意 source の不在では false に しない。完全な外部照合が必須の利用者には --require-github を設け、 その場合のみ ok=false と終了コード 3 を返す(2 は「レポートを作れない」)。 - limitations[] に reason・detail・observed_at を残し、text/markdown 双方に出す。 - gh 照会に timeout を与える。timeout のない任意 source は任意ではない。 副次的に、gh 不在が原因で main で失敗していた BHUSA 系 12 件が通るように なった。tests 全体 863 passed / 4 skipped、compileall OK。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SsboPSj6GyJju6mTXwHHjq
01rabbit
marked this pull request as ready for review
September 20, 2026 13:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #420.
欠陥は 2 つあり、後者のほうが危険だった
1. 未捕捉の
FileNotFoundErrorgh不在時、例外はsubprocess.runの戻り値ではなく呼び出し自体から送出される。周囲のexcept ValueErrorは最初から到達できなかった。main の版で再現:2. 捕捉後、不在が健全として読まれていた
取得失敗で
issuesが空になり、open_issuesが 0 件として扱われ、overall_stateがfreeze-readyに到達し得た。外部照会が落ちたことを理由に、レポートが最も強い判定へ昇格する経路である。リポジトリにコミットされている
docs/issues/bhusa-2026-vegas-readiness/15-status.mdが現にこの出力を持っている(この PR では再生成していない。生成物の更新は操作者の行動であり、テスト実行の副作用として入れるべきものではない):決定
GitHubUnavailableに一本化。ValueError(必須ローカル検査の失敗)とは別の型にするgh_not_installed/gh_not_executable/gh_timed_out/gh_not_authenticated/gh_rate_limited/gh_failed/gh_returned_unparseable_output0ではなくNone、描画はunknownfreeze-readyavailability == "available"を要求ok--require-githubのときのみok=falseと終了コード 3(2 は「レポートを作れない」)limitations[]reason/detail/observed_atを残し text・markdown 双方に出すgh照会に 20 秒。timeout のない任意 source は任意ではない理由を畳まないのは、操作者の次の行動が異なるためである。CLI の導入、認証情報の更新、rate limit の待機は別の作業であり、「gh が失敗した」だけのレポートは読み手に調べ直させる。
生存した変異と、その原因
W3(
FileNotFoundErrorハンドラの削除)が最初の走行で生存した。OSErrorはその上位クラスであり、下の一般ハンドラがgh_failedとして飲み込む。そしてわたくしのテストは、ghが入った runner でも通るよう理由の集合を緩く受け入れていた。結果として、CLI を持たない機械に「CLI の失敗を調査せよ」と告げる分岐が無防備に残っていた。修正として、理由の固定は環境に問わず
_run_commandを差し替えて行うテストに分けた。周囲の環境に聞くテストは「何も漏れないか」だけを問い、それはどこで走っても真である。freeze-readyの availability 条件を外すFileNotFoundErrorハンドラ削除ok=False(任意性の否定)PermissionErrorハンドラ削除副次的な結果
gh不在が原因で main で失敗していた BHUSA 系 12 件が通るようになった。bhusa-reportが終了コード 2 を返していたためである。範囲外として記録する点
テスト実行が
docs/issues/bhusa-2026-vegas-readiness/配下の生成物を書き換える(--write-status-docの既定パスがリポジトリ内を指すため)。この PR では毎回 revert した。別の欠陥であり、この PR を広げない。🤖 Generated with Claude Code
https://claude.ai/code/session_01SsboPSj6GyJju6mTXwHHjq
Generated by Claude Code