Skip to content

実装: CI: visual-impact-policy job の PR_NUMBER 未定義時 gh api pulls/ 404 を防ぐ #2594

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "push イベントで visual-impact-policy ジョブが常に失敗し ci-verdict-summary artifact が main tip commit で得られない構造的欠陥を修正する"
change_kind: workflow

Parent Issue

なし(単独改善。related: #2155)

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

なし

Outcome

.github/workflows/ci.yml の visual-impact-policy job の「Write PR body to file」step が、github.event.pull_request.number が未定義(push イベント、または PR に紐付かない workflow_dispatch)の場合でも gh api repos/.../pulls/ への空 PR 番号呼び出しで 404 失敗しないよう修正されたコミットが main にマージされ、actionlint .github/workflows/ci.yml が引き続き PASS し、pull_request イベント経路の挙動が byte-for-byte 不変であることが確認できる状態。

Runtime Verification Applicability

  • decision: deferred
  • reason: このバグは push(または PR に紐付かない workflow_dispatch)イベントでのみ再現する。この repo の通常 CI 実行は PR trigger のため、修正 PR 自体の CI 実行では再現条件を満たさない。
  • deferred_destination: この PR 自身が squash-merge され main への push イベントとして実行される、次の実 CI 実行
  • deferred_verification_condition: PR マージ後の push イベントで起動した .github/workflows/ci.yml の visual-impact-policy job(gh run list -R squne121/loop-protocol --workflow ci.yml --json event,headSha,conclusion で event=="push" かつマージコミット SHA の run を特定)が conclusion: success であることを確認する。マージのブロック条件にはしない(PR 本文にマニュアル確認ノートとして残す)。

In Scope

  • .github/workflows/ci.yml の visual-impact-policy job の「Write PR body to file (untrusted input -- never shell-expanded)」step に、PR_NUMBER が空の場合に gh api repos/.../pulls/ を呼ばず空の pr_body.md を書き出すガードを追加する
  • ガードは同ファイル内の既存パターン(line ~3468 の PR_NUMBER: ${{ github.event.pull_request.number || 0 }} および line ~4038 の GH_PR_NUMBER: ${{ github.event.pull_request.number || '' }} + 使用前の空文字チェック)に倣う。新しいパターンを発明しない
  • pull_request イベント経路(PR_NUMBER が非空)の挙動は完全に不変とする(byte-for-byte 同一の pr_body.md 内容・同一の後続 step 挙動)
  • .github/workflows/ci.yml に既存の regression test harness がこの step 用に存在する場合、そのテストへ追加検証を行う(git grep -l "visual-impact-policy" tests/ .github/ で確認。本 Issue 起票時点で .github/workflows/ci.yml と .github/pull_request_template.md と .github/workflows/visual-impact-trusted-consumer.yml がヒットしたが、専用 unit-test harness は確認できなかった)
  • harness が存在しない場合は actionlint .github/workflows/ci.yml の PASS とこの Issue に記載した再現手順・修正内容を明記した PR 本文を最小検証として採用する(新しいテストフレームワークを本 Issue のためだけに作らない)

Out of Scope

  • commit 63ef5f6598125f9c0d0177e3a5336aa1cfba031e に対する遡及的な ci_verdict_summary_v2 取得(構造的に不可能。当該 commit が push された時点の ci.yml に既にこのバグが含まれているため、後続の修正 commit で main の tip が新しい SHA に変わっても、古い run の failed job を rerun すれば checkout されるのは push 時点の古いコードであり、後の修正 commit ではない)
  • .github/workflows/ci.yml の changed-paths / BASE_SHA / HEAD_SHA の計算ロジック変更(push イベントで BASE_SHA == HEAD_SHA になる別件の挙動。今回の 404 failure の原因ではないため対象外)
  • #2155 / #2119 / #2554 / #2555 / #2422 / #2423 / #2424 の本文・Allowed Paths・Delivery Rule・AC の変更(一切触れない)
  • 新規の blocks=22 / blocks=N production benchmark dispatch の実行(人間または 検証: #2119 AC9/AC10 の close-grade 実CI証跡を確認する #2155 の別途継続判断に委ねる)
  • python-test-core / python-test job など、同じ run(34256855152)で別途失敗していた他 job の修正(別件。本 Issue のスコープ外)

Acceptance Criteria

  • .github/workflows/ci.yml の visual-impact-policy job の「Write PR body to file」step が、PR_NUMBER が空文字の場合に gh api repos/.../pulls/ を呼ばず空の pr_body.md を書き出す
  • pull_request イベント経路(PR_NUMBER が非空)で、修正前後の step の実行内容(gh api 呼び出しの有無・引数)が変わらない
  • actionlint .github/workflows/ci.yml が exit 0 で PASS する
  • 修正後の該当 step の run: ブロックが、同ファイル内の既存ガードパターン(|| 0 または || '' + 空文字チェック)と同型の記述になっている

Verification Commands

$ actionlint .github/workflows/ci.yml
$ rg -n "Write PR body to file" .github/workflows/ci.yml
$ rg -c "PR_NUMBER: \${{ github.event.pull_request.number }}" .github/workflows/ci.yml
$ rg -c "Write PR body to file" .github/workflows/ci.yml

Allowed Paths

  • .github/workflows/ci.yml
  • 対応する専用 regression test ファイル(git grep -l "visual-impact-policy" tests/ .github/ で発見できる既存 harness がある場合のみ。本 Issue 起票時点では専用 unit-test harness の存在は確認できていない)

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • .github/workflows/* の編集は CI 動作に直結するため、変更時は PR レビューで人間承認を必須とする(.github/CLAUDE.md 参照)。この Issue の実装 PR は人間承認を経てからマージする

Required Skills

  • なし

Required Design References

  • docs/dev/ci-performance.md

Scope Delta(任意)

N/A

Notes for Reviewer

Delivery Rule

1 Issue = 1 PR。worktree で作業し、Draft PR を既定とする。.github/workflows/* 変更のため、マージ前に人間レビュー承認を必須とする(.github/CLAUDE.md)。

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Sep 8, 2026
  2. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-08T19:19:18Z)

    • PR: fix: visual-impact-policy job の PR_NUMBER 未定義時 gh api pulls/ 404 を防ぐ #2595
    • Worktree: .claude/worktrees/issue-2594-visual-impact-pr-number-guard
    • Branch: worktree-issue-2594-visual-impact-pr-number-guard
    • Verification: actionlint PASS / 3 rg VC PASS / pnpm typecheck・lint・test(1939 件)・build 全 PASS / gemini-cli-headless-delegation model routing pytest 24 passed
    • .github/workflows/* 変更のため、.github/CLAUDE.md に従いマージ前に人間レビュー承認が必須
    • 後続: PR レビュー(人間承認)→ マージ → 次回 push イベントでの deferred runtime verification 確認 → post-merge-cleanup
  3. squne121 commented on Sep 8, 2026

    @squne121
    OwnerAuthor

    implement-issue: 更新 (2026-09-08T19:45:11Z)

    PR #2595 に 2 回目のコミットを追加。1 回目のコミットは if/else 分岐で pr_body.md を条件ごとに別行で書いており、既存の regression harness scripts/agent-ops/tests/test_pr_body_acquisition_parity.py(tests/ .github/ 配下ではないため Issue 起票時のプリフライト grep では発見できなかった)に「acquisition 行後の再書き込み」として誤検知され python-test-core を落としていた。: > pr_body.md を if/else の前に一度だけ置き、PR_NUMBER 非空時のみ direct な gh api ... > pr_body.md で上書きする形に修正し、全 CI check が PASS(visual-impact-policy 含む)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions