Repository navigation
fix: deploy-pr preview asset liveness check の404タイムアウトを調査・修正する - #1358
Conversation
…1357) The `Verify preview assets are live` step in deploy-pages.yml failed intermittently with 404 timeouts unrelated to PR diff content (observed during PR #1349 review, also seen on PR #1274). This tunes the fetch_pages_url_with_bounded_retry polling logic: - Replace the fixed `sleep 5` retry interval with an exponential bounded backoff (initial_delay=2s, max_delay=20s, doubling per attempt). - Introduce a single overall_deadline shared across the index page and every asset URL, instead of each URL getting its own independent 180s budget that stacks with the number of assets checked. - Extend the retriable HTTP status set with 409 (Pages deployment conflict during a concurrent publish) and 425 (too early / origin not yet ready), with an inline comment documenting why each status is treated as transient. - Emit structured retry logs (label=preview-index|preview-asset, attempt=, elapsed=, next_sleep=) to make future flake investigation from CI logs tractable. deploy-main job logic and the gh-pages commit message string are untouched; only the deploy-pr job's live asset check step changed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
CI log investigation (run 28757862903 / PR #1352, 28751177802 / PR #1349, 28749187051 / PR #1345) shows the index preview URL returning a sustained 404 for the entire previous 180s per-URL budget with no intervening 200 response, while the same repository's deploy-main job (same GitHub Pages Settings/Source) never exhibits this failure. This is consistent with GitHub Pages CDN propagation lag for freshly published pr-<n>/ subdirectories exceeding 180s on occasion, rather than a Pages Settings/Source misconfiguration (tracked separately in #1315). Bump the shared overall_deadline from 240s to 300s to give the index + asset checks more headroom within the new shared-budget model. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1358 closed). |
|
LOOP_VERDICT_V2 verdict: APPROVE. reviewed_head_sha: 57b4b38. merge_ready: true. mergeability mergeable: MERGEABLE, merge_state_status: CLEAN. blockers: none. required_auto_actions: none. auto_fix_applied: none. follow_up_issue_requests: none. allowed_paths_gate status: ok, changed_files_source: git_diff_name_status_find_renames_z, changed_files: .github/workflows/deploy-pages.yml only. allowed_paths_gate_source: review_subagent. producer_role: review_subagent. worker_report_used_as_canonical: false. |
|
LOOP_VERDICT_V2 rationale (review_subagent, PR pr-review-judge skill). Allowed Paths: gh pr view --json files and local git diff --name-status -M -z merge-base head both show a single changed file, .github/workflows/deploy-pages.yml, which is the sole Issue #1357 Allowed Path (no rename involved). AC1 through AC15: verified directly against git show head colon path content by this SubAgent, not by trusting worker self-report. sleep 5 removed. initial_delay=2 and max_delay=20 named variables present. old SECONDS plus 180 fixed deadline removed. shared overall_deadline equal to SECONDS plus 300 present. retry statuses include 409 and 425. transient rationale documented in comments. structured log tokens label=preview-index, label=preview-asset, attempt=, elapsed=, next_sleep= all present. deploy-main chore commit string unchanged. Verify preview assets are live step appears exactly once. AC16: PR body documents three prior failing runs, ids 28757862903, 28751177802, 28749187051, all index URL 404 for the full 180s budget, and states the timing race conclusion versus deferring Pages Settings diagnosis to Issue 1315. CI evidence: ci_verdict_summary.py against expected head sha 57b4b38 returned status all_pass, no stale or failed or pending checks. Additionally the real deploy-pr job itself, which performs the live GitHub Pages asset check this PR modifies, completed with conclusion success at that same head sha, giving direct runtime confirmation beyond static grep. Safety Claim Gate: workflow path change is safety sensitive. PR body includes a Safety Claim Matrix with a Not controlled row for CDN propagation delay pointing to follow up Issue 1315, consistent with evidence. Schema Change Applicability not_schema_change is correctly scoped since only retry backoff logging logic changed. PR body sections for AC coverage, verification command results, and Allowed Paths compliance are all present without placeholders, and Closes 1357 is included. No blockers identified, so required_auto_actions is empty and merge_ready is true given mergeable MERGEABLE and merge_state_status CLEAN. Non blocking note: workflow file editing requires human_review_required per dot github CLAUDE.md policy, which the PR body already states, and this is a separate human merge gate independent of this technical verdict. Also non blocking: CI_TEST_PERFORMANCE_DECISION_V1 is not present in the PR body, but per docs/dev/agent-skill-boundaries.md the pr-reviewer consumer routing for that skill is explicitly documented as design only with real enforcement deferred to a follow up Issue, and it is not part of the pr-review-judge skill required reference set, so it is not treated as a blocker here. |
判定REQUEST_CHANGES。 CI自体は head 良い点変更範囲は 固定
Blocker:
|
- Blocker: overall_deadline を実際にhard deadlineにする。curl --max-time を
残り時間でcap(attempt_max_time)し、curl実行前に残り時間<=0ならエラーで
抜ける。retryのsleep前にも残り時間を再計算しnext_sleepをcapする。
- Major: retry対象statusのコメントをobserved/defensiveの区別に修正。
今回実観測されたのは404のみ。403/409/425等は今回未観測のdefensive retryと
明記(425文字列自体はAC7維持のため残す)。
- Minor: asset URL fetchにも ?cache_bust=${GITHUB_SHA} を追加し index/asset
で診断の一貫性を揃える。
Co-Authored-By: Claude Sonnet 5 <[email protected]>
REQUEST_CHANGES 対応報告(fix_delta)対象: REQUEST_CHANGESコメント 対応内容
「live checkが最新PR headの成果物であることの証明」( 検証結果
|
|
LOOP_VERDICT_V2 verdict: APPROVE. reviewed_head_sha: e379d5f. merge_ready: true. mergeability mergeable: MERGEABLE, merge_state_status: CLEAN. blockers: none. required_auto_actions: none. auto_fix_applied: none. follow_up_issue_requests: none. allowed_paths_gate status: ok, changed_files_source: github_pull_request_files_api_with_previous_filename, changed_files: .github/workflows/deploy-pages.yml only. allowed_paths_gate_source: review_subagent. producer_role: review_subagent. worker_report_used_as_canonical: false. 前回REQUEST_CHANGES 4点の再確認(コード直読・head e379d5f0取得):
AC1〜AC16: 全て実ファイル内容で個別確認し充足。CI: ci_verdict_summary.py --expected-head-sha e379d5f で all_pass。deploy-prジョブ自体がhead e379d5f0でSUCCESS(実運用でのランタイム確認)。Allowed Paths gate: allowed_paths_review_gate.py で status ok(.github/workflows/deploy-pages.ymlのみ)。Blockerなし。 |
敵対的レビュー結果判定: 条件付きApprove。 良い点変更範囲は 前回の blocker だった 現 head の CI では
Major 1: live check が「最新PR headの配信」を証明していない現 workflow は build 前に しかし live check 側は、index が200になること、index に これは配布物ゲートとしては穴です。 したがって、理論上は過去runの index/assets が残っていて200を返すだけでも live check が通る余地があります。PR本文もこの点を「live checkが最新PR headの成果物であることの証明」は未実装・スコープ外として認めています。 推奨修正: expected_sha="${{ steps.commit-sha.outputs.sha }}"
live_sha_seen=0
asset_i=0
for asset_path in "${asset_paths[@]}"; do
asset_i=$((asset_i + 1))
asset_tmp="/tmp/preview-asset-${asset_i}.bin"
fetch_pages_url_with_bounded_retry \
"preview-asset" \
"https://${GITHUB_REPOSITORY_OWNER}.github.io${asset_path}?cache_bust=${GITHUB_SHA}" \
"$asset_tmp"
case "$asset_path" in
*.js|*.css|*.html)
if grep -aFq "$expected_sha" "$asset_tmp"; then
live_sha_seen=1
fi
;;
esac
done
if (( live_sha_seen != 1 )); then
echo "ERROR: live preview assets do not contain expected commit SHA: $expected_sha" >&2
exit 1
fiこの修正を入れない場合は、「live previewが最新PR head SHAを含むことを検証する」follow-up Issue をマージ前に起票するのが最低ラインです。「検討」だけでは弱いです。 Major 2: #1315 未解決なので、根本原因はまだ閉じていない#1315 は GitHub Pages Settings Source の read-only 診断Issueで、 PR #1358 は「404 flakeへの緩和策」としては成立しています。しかし「原因を timing race と確定して修正した」と読むと過剰です。#1315 の背景にも、原因候補は Pages Settings 誤設定または 推奨: PRタイトルまたは本文のトーンは「修正」よりも「緩和」に寄せる方が正確です。マージ時も #1315 を未解決の関連リスクとして残すべきです。 Major 3: retry status の集合はまだ広い現在の retry 対象は curl の通常 retry transient HTTP status は主に 現在のコメントは「404のみ観測、他は defensive」と整理されており前回より改善しています。ただし # The non-404 statuses below are defensive retries only.
# They are not observed for #1357 and are not treated as a documented
# GitHub Pages readiness contract.さらに堅くするなら、 Moderate: concurrency group を占有するため、step timeout も欲しい
Bash側の hard deadline は実装済みですが、shellの予期しない分岐・curl以外の停止・将来変更の回帰に備え、 - name: Verify preview assets are live
timeout-minutes: 7
id: preview-assets-live
shell: bashMinor: asset 抽出は「全配布物検証」ではない現在は HTML から PRコメントの “verified live assets” はやや強い表現です。現実には「indexから直接参照された src/href asset のlive確認」です。配布物の厳密性を上げるなら、 Minor: retry失敗時の診断bodyが古い可能性deadline超過時に 各curl前に以下を入れるだけで診断の混線を避けられます。 rm -f "${output}.tmp"最終マージ条件私なら次の条件で進めます。
GitHubへのレビュー投稿は行っていません。 |
- add timeout-minutes: 7 to the "Verify preview assets are live" step
as a defense-in-depth guard against holding the shared deploy-pages
concurrency group indefinitely
- clear stale "${output}.tmp" before each curl attempt in
fetch_pages_url_with_bounded_retry so a prior attempt's tmp content
cannot leak into a later attempt's deadline-exceeded diagnostics
- soften the retry-eligible status comment: it no longer implies a
documented GitHub Pages/CDN transient-behavior contract; the
non-404 codes are described as defensive-only and unobserved for
#1357
Live-preview head-SHA verification is intentionally out of scope here
and tracked as a separate follow-up issue per the review feedback.
Closes #1357
|
敵対的レビュー(条件付きApprove、コメント)のうち、Allowed Paths 内で完結する低リスクな指摘4点に対応した(head 対応内容
対応しないこと(スコープ外)
検証
|
|
follow-up issue #1360 を本文に反映した(「follow-up issue(起票中)」セクションと Safety Claim Matrix の live-preview SHA 行の Follow-up セルを更新)。 |
|
test minimal comment |
LOOP_VERDICT_V2verdict: APPROVE 根拠(iteration 3、最終ラウンド。root権限では gh pr review --approve が gh_mutation_denied でブロックされるため PR コメントとして投稿)
|
Summary
.github/workflows/deploy-pages.ymlのdeploy-prjob にあるVerify preview assets are liveステップが、PR差分と無関係な断続的404タイムアウトで失敗する事象(PR #1349 レビュー時に観測、PR #1274 等でも再現)を調査し、fetch_pages_url_with_bounded_retry関数のポーリング・タイムアウト・リトライ設定を見直した。過去のCI失敗ログの傍証からは timing race 仮説(新規pr-<n>/サブディレクトリの CDN 伝播ラグ)に沿う挙動が見えているが、これは仮説の域を出ておらず、本PRはその仮説に対する緩和策(overall_deadline 拡大・backoff・ログ強化・concurrency占有への防御)に限定される。GitHub Pages Settings Source の設定状態そのものの診断(Issue #1315)は本PRでは解決していない。主な変更点:
sleep 5のリトライ間隔を、attempt ごとに倍増する bounded exponential backoff(initial_delay=2/max_delay=20)に置き換えた。overall_deadline(300秒)を導入し、URLごとに180秒が独立して積み上がる旧来の挙動を除去した。409(Pages デプロイ競合)・425(too early)を追加し、なぜ各ステータスを defensive retry として扱うかの理由をコメントに残した。label(preview-index / preview-asset)・attempt・elapsed・next_sleepを含む構造化ログを stderr に出力するようにした。レビュー対応(REQUEST_CHANGES fix_delta, head e379d5f)
PRレビューコメント の指摘に対応した。
overall_deadlineが実際には hard deadline になっていなかった。curl --max-timeを固定20秒で呼んでいたため、deadline直前で呼ばれたcurlが最大20秒余分にブロックしうる問題と、backoffのsleepがdeadlineを考慮せず長く眠りうる問題があった。attempt_max_time(overall_deadline - SECONDSでcapした値)をcurl --max-timeに渡し、curl実行前に残り時間が0以下ならエラーで即座に抜けるようにした。retryのsleep前にも残り時間を再計算し、next_sleepが残り時間を超えないようcapした。これによりoverall_deadlineが名実ともに hard wall-clock deadline になった。404のみだった。コメントを404=observed(今回実観測)、403/409/425/その他=defensive(今回は未観測だが GitHub Pages/CDN の既知の一時的挙動への安全策)と明記し直した。425は HTTP semantics 上 Pages readiness と直結する保証がないため、AC7 のgrep -q '425'VC を壊さない形でコメント表現のみを修正した(retry対象からは削除していない)。gh api repos/squne121/loop-protocol/pagesは root checkout のgh api実行制限により本セッションでは取得できなかった。代わりに、Pages Settings Source の診断自体は Issue 調査: deploy-pr job の live asset check green 化のための GitHub Pages Settings Source 診断 #1315 が未完了であることを明記し、本PRは timing race 仮説への緩和策(overall_deadline拡大・backoff・ログ強化)に限定される旨を「調査結果(AC16)」節に追記した。?cache_bust=${GITHUB_SHA}を追加し、診断の一貫性を揃えた。その他の指摘(「live checkが最新PR headの成果物であることを証明していない」=
VITE_LOOP_COMMIT_SHAの grep 検証を live check にも追加する提案)は本Issue(#1357)のスコープ外と判断した。対応する場合は別Issueでの follow-up 起票を検討する。レビュー対応(2回目 fix_delta, 条件付きApprove, head 8646799)
敵対的レビューコメント のうち、Allowed Paths 内で完結する低リスクな指摘のみを追加対応した。live preview のSHA検証(スコープ拡大を伴う指摘)は対応せず、follow-up issue #1360 として起票済みである(下記参照)。
timeout-minutesが未設定だった。Verify preview assets are liveステップにtimeout-minutes: 7を追加し、concurrency group(deploy-pages-gh-pages)を無期限に占有しない防御層を追加した。.tmpファイルが診断に混線する可能性があった。fetch_pages_url_with_bounded_retry内、各curl実行の直前にrm -f "${output}.tmp"を追加し、前回attemptの古いtmp内容が deadline-exceeded 時の診断出力に残らないようにした。409/425を含む)自体は変更していない。本PRの変更は、404タイムアウトの原因を timing race と断定して「修正した」ものではなく、あくまで timing race 仮説に対する緩和策(overall_deadline の hard 化・backoff・concurrency占有への防御・ログ強化)である。GitHub Pages Settings Source の設定状態そのものの診断(Issue #1315)は本PRでは未解決のまま残る。
follow-up issue(起票済み)
「live previewが最新PR head SHAを含むことを検証する」follow-up issueとして #1360 を起票した。
調査結果(AC16)
過去の deploy-pr 失敗 CI run を確認した結果:
404を返し続けタイムアウト404)404)3件とも、途中で一度も
200を返さず旧来の180秒予算をまるごと404のまま消費してタイムアウトしている(他のHTTPステータスへの遷移なし)。同一リポジトリ・同一 GitHub Pages Settings/Source を使うdeploy-mainjob は継続して成功しており、Settings/Source に構造的な不備があるとは考えにくいという傍証にはなるが、Pages Settings Source の設定状態そのものの診断は Issue #1315 が別途担当しており未完了である。本PRはその診断を代替するものではなく、あくまで「新規に作成されたpr-<n>/サブディレクトリが GitHub Pages の CDN に伝播しきるまでのラグが既存の180秒固定予算を時折超える」という timing race 仮説への緩和策(overall_deadline拡大・backoffの適正化・構造化ログ追加)に限定される。伝播ラグそのものの根絶や Settings/Source 側の恒久対応は #1315 に委ねる。Checks
pnpm typecheck: PASSpnpm lint: PASSpnpm test: PASS(1427 tests passed / 92 files)pnpm build: PASSuv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py: PASS(21 tests)yaml.safe_load): OKbash -n(${{ }}を含む各run:ブロックの構文チェック): OKSchema Change Applicability
.github/workflows/deploy-pages.yml内のリトライ・バックオフ・ログ出力ロジックの変更のみであり、他コンポーネントが消費する schema / contract の変更は含まない。Schema Consumer Inventory
N/A(Schema Change Applicability が
not_schema_changeのため、consumer inventory の記載は不要)Safety Claim Matrix
deploy-mainjob のロジックおよびchore: deploy main to gh-pagesコミットメッセージ文字列に影響を与えないgrep -c "chore: deploy main to gh-pages"が変更前後で不変)/diff はdeploy-prjob のVerify preview assets are liveステップのみに限定Verify preview assets are liveステップは1個のまま重複・分割されていないgrep -c 'Verify preview assets are live'== 1).github/workflows/deploy-pages.ymlの編集は人間レビュー必須(human_review_required).github/CLAUDE.mdの編集ガード方針に従い、本PRは人間承認を必須とするoverall_deadlineは curl呼び出し・retry sleep双方を含む real hard wall-clock deadline であるattempt_max_timecap / pre-curl残り時間チェック / pre-sleep残り時間cap(本PR差分)Verify preview assets are liveステップが concurrency group を無期限に占有しないtimeout-minutes: 7を追加(本PR差分)VITE_LOOP_COMMIT_SHAgrep等)Notes
.github/workflows/deploy-pages.ymlの編集は CI 動作に直結するため、本PRのマージには人間承認が必須(.github/CLAUDE.mdの編集ガード方針)。.github/workflows/deploy-pages.ymlのみを編集(Allowed Paths と完全一致)not_applicable(本Issueの全ACは grep によるワークフロー定義の静的検証で完結。実際のretry/backoff挙動がGitHub Pages環境で機能することの動作検証は本PR自身がトリガーする deploy-pr job のCI実行観測に委ねる)deploy-mainjob のロジック変更、GitHub Pages Settings(Source)の設定変更自体(Issue 調査: deploy-pr job の live asset check green 化のための GitHub Pages Settings Source 診断 #1315、診断未完了)、deploy-prを required status check にする変更、cleanup-prjob の変更、deploy-pr内の他ステップの変更、live preview の PR head SHA 検証(follow-up issue 実装: deploy-pr の GitHub Pages preview liveness check に配信済み成果物のcommit SHA検証を追加する #1360 で対応予定)deploy-prjob 自体が今回の変更をトリガーする最初の実地検証となる(GitHub Pages への実際のライブ確認)