Skip to content

実装: CI Check Wait Normalizer を追加し pending polling / pre-existing issue 判定を統一する #1055

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1047"
goal_ref: "PR checks の待機・pending 判定を deterministic script に集約し、Skill が shell sleep を直接組み立てずに head-scoped machine output を消費できるようにする"
change_kind: workflow

Parent Issue

#1047

Parent Goal Ref

  • Goal: sleep && gh pr checks ... を Skill 文書から直接組み立てる運用をやめ、bounded polling・timeout・head SHA drift 判定を wait_pr_checks.py の machine output に集約する
  • Desired Destination: pr-review-judge 系の後続作業が PR_CHECKS_WAIT_RESULT_V1 を正本として required checks の待機結果を再利用できる状態

Current Validated Scope

  • .claude/skills/pr-review-judge/scripts/wait_pr_checks.py を新規追加する
  • .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py を新規追加する
  • 本 Issue は script / test のみを対象にし、Skill / agent 文書の置換は follow-up に分離する

Remaining Parent Gaps

  • Issue 8〜9 が残る
  • raw gh pr checks 呼び出し経路の文書置換は別 Issue で扱う

Background

親 Issue #1047 は、PR review / implementation loop 周辺の運用改善を child issue に分解して進めている。現状は required checks の待機と結果要約に複数の経路があり、shell sleep loop・pending 判定・timeout 時の扱い・head SHA drift 判定が利用側ごとにばらつく。

anchor comment https://github.com/squne121/loop-protocol/issues/1055#issuecomment-4846148706 では、Allowed Paths と Outcome の矛盾、既存 ci_verdict_summary.py / wait_ci_checks.py との責務重複、pre-existing issue 判定の責務越境、実待機動作の検証不足が指摘されている。

本 Issue ではそれらを踏まえ、wait_pr_checks.py を「required PR checks の bounded polling と head-scoped machine output」に責務限定し、pre-existing / out_of_scope の裁定は既存 VC_ADJUDICATION_RESULT_V1 系の責務として再実装しない。

Outcome

wait_pr_checks.py が --repo / --pr / --expected-head-sha を受け取り、required PR checks を bounded polling した結果を PR_CHECKS_WAIT_RESULT_V1 として出力する。結果には少なくとも decision、checks[]、pending_count、failed_blocking_count、expected_head_sha、current_head_sha、timed_out を含み、timeout 時は最後に観測した checks[] を保持したまま decision: human_judgment を返す。uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q が PASS し、script が required checks 0 件を pass 扱いしないこと、head SHA drift を fail-closed で扱うこと、AI agent が shell sleep loop を組まずに呼び出せることが検証されている。

In Scope

  • .claude/skills/pr-review-judge/scripts/wait_pr_checks.py に PR_CHECKS_WAIT_RESULT_V1 を実装する
  • required PR checks の bounded polling、timeout、head SHA drift、machine-readable summary を実装する
  • timeout 時の最終観測 checks[] 保持と decision: human_judgment を実装する
  • required checks 0 件を pass 扱いしない fail-closed 判定を実装する
  • exact 条件での non-blocking check 設定を実装する
  • .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py に pending→pass / pending→fail / timeout / head SHA drift / no required evidence の分岐テストを追加する
  • AI agent から --repo / --pr / --expected-head-sha を明示して呼べる CLI 契約を固定する

Out of Scope

  • pre-existing / out_of_scope failure の独自裁定ロジック追加や VC_ADJUDICATION_RESULT_V1 の責務変更
  • .claude/skills/pr-review-judge/SKILL.md、.claude/agents/pr-reviewer.md、.claude/agents/pr-reviewer-lite.md などの大規模文書改修
  • ci_verdict_summary.py や wait_ci_checks.py の責務移動
  • GitHub Actions workflow 自体の required/non-required 設定変更
  • 実サービス側 CI 定義の変更や branch protection 設定変更

Acceptance Criteria

  • AC1: wait_pr_checks.py が追加される
  • AC2: PR_CHECKS_WAIT_RESULT_V1 を出力し、少なくとも decision / checks[] / pending_count / failed_blocking_count / expected_head_sha / current_head_sha / timed_out を含む
  • AC3: pending check がある場合 script 内で bounded polling する
  • AC4: timeout 時は最後に観測した checks[] を保持したまま decision: human_judgment を返す
  • AC5: --repo / --pr / --expected-head-sha を受け取り、head SHA drift 時は stale_head_sha を返す
  • AC6: required checks 0 件を pass 扱いせず、no_required_evidence または同等の fail-closed decision に倒す
  • AC7: exact 条件での non-blocking check 設定を持ち、required 判定の正本を壊さない
  • AC8: uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q が PASS する
  • AC9: pending→pass / pending→fail / timeout / head SHA drift / no required evidence を少なくとも unit test または fixture-based test で固定する

Verification Commands

# AC1
# baseline-expect: fail
$ test -f .claude/skills/pr-review-judge/scripts/wait_pr_checks.py

# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k pr_checks_wait_result_v1

# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k pending_then_pass

# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k timeout_returns_human_judgment

# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k head_sha_changed

# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k no_required_evidence

# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k non_blocking

# AC8
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q

# AC9
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q -k "pending_then_fail or timeout or no_required_evidence"

Allowed Paths

  • .claude/skills/pr-review-judge/scripts/wait_pr_checks.py
  • .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py

Runtime Verification Applicability

  • decision: deferred
  • reason: 実 pending PR を常時用意できる保証はないが、AI agent が安全に消費できる polling / timeout / head SHA drift 契約の確認を実装完了前に明示する必要があるため
  • deferred_destination:
    • destination_type: test
    • destination_ref: .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py
  • deferred_verification_condition: pending→pass / pending→fail / timeout / head SHA drift を fixture-based test または実 PR で再現できる状態になった時点で runtime verification を完了する
  • required_runtime_checks:
    • wait_pr_checks.py の CLI が --repo / --pr / --expected-head-sha を必須入力として fail-closed に動作すること
    • timeout 時に最終観測 checks[] を保持したまま decision: human_judgment を返すこと
  • fallback_policy:
    • 実 pending PR を使った確認が困難な場合は fixture-based test で pending→pass / pending→fail / timeout / head SHA drift を再現し、その限界を本文または結果報告で明示する

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • raw gh pr checks の既存利用経路を同時に置換しないと完了条件を満たせないと判明した場合
  • ci_verdict_summary.py / wait_ci_checks.py と整合しない独自 schema または判定規則が必要だと判明した場合

Required Skills

  • Python 3(subprocess / time / json / argparse)

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jun 20, 2026
  2. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-07-01 02:10:26

    #1055
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    対象Issueを起点に、関連Issue/PR・コメント・実装・配布物を確認し、外部仕様や実装例も照合して批判的にレビューします。まずGitHub側の一次情報とリポジトリ文脈を取得します。


    chatgpt response

    Issue #1055はコメントなしで、親Issue #1047配下の限定スコープです。既存CI判定資産との重複統合と、pr-reviewer-lite の raw gh pr checks 経路の取り残しを重点確認します。


    chatgpt response

    結論: NEEDS-FIX

    #1055 の方向性、つまり「PR checks の pending 待機・timeout・non-blocking 例外を決定論的 script に集約する」こと自体は正しいです。ただし、現状の Issue 契約のまま実装すると、次の 3 点で高確率に壊れます。

    1. Allowed Paths と Outcome が矛盾しています。 実装: CI Check Wait Normalizer を追加し pending polling / pre-existing issue 判定を統一する #1055 は wait_pr_checks.py とテストだけを Allowed Paths にしていますが、Outcome では Skill 文書内の sleep && gh pr checks 削除まで要求しています。これは現在の契約では Stop Condition です。
    2. 既存の CI 判定資産と三重化します。 pr-review-judge には既に ci_verdict_summary.py があり、impl-review-loop には既に bounded polling 用の wait_ci_checks.py があります。実装: CI Check Wait Normalizer を追加し pending polling / pre-existing issue 判定を統一する #1055 が新規 schema を独自に持つなら、既存の CI_VERDICT_SUMMARY_V1 / CI_WAIT_RESULT_V1 と齟齬が出ます。
    3. pre-existing issue 判定をここで実装すると 実装: VC failure adjudicator を追加し pre-existing / out-of-scope 判定を構造化する #1115 / PR feat(impl-review-loop): add VC adjudication artifact #1250 と責務衝突します。 pre-existing / out-of-scope failure は既に VC_ADJUDICATION_RESULT_V1 として構造化され、baseline/current/diff/allowed paths/failure_keys を使う fail-closed 裁定に寄せられています。実装: CI Check Wait Normalizer を追加し pending polling / pre-existing issue 判定を統一する #1055 の wait script はこの裁定を「消費」すべきであって、再判定すべきではありません。

    #1055 自体にはコメントがなく、Issue discussion による補足は確認できませんでした。 親 Issue #1047 は、EACCES/posix_spawn、worktree_scope_guard 誤ブロック、PR body hygiene、contract snapshot、CLI 引数不整合などを 9 件の child issue に分解する運用改善トラックであり、#1055 はそのうちの P1 子 Issue です。


    敵対的レビュー

    1. Allowed Paths が現実の変更対象を覆っていない

    #1055 の Allowed Paths は以下 2 ファイルだけです。

    .claude/skills/pr-review-judge/scripts/wait_pr_checks.py
    .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py
    

    一方で Outcome は「Skill 文書内の sleep && gh pr checks が削除されている」ことまで要求しています。 これは実装前に contract を修正しないと矛盾します。

    実際、リポジトリ内では gh pr checks 参照が pr-review-judge/SKILL.md、pr-reviewer.md、pr-reviewer-lite.md、wait_ci_checks.py などに散っています。検索結果でも pr-reviewer.md、pr-reviewer-lite.md、pr-review-judge/SKILL.md、ci_verdict_summary.py が該当しています。

    特に pr-reviewer-lite.md は Gate 2 で raw gh pr checks <PR番号> を直接実行し、no checks / pending を REQUEST_CHANGES に倒しています。 pr-reviewer.md の description も Bash で gh pr checks を実行すると明記しています。

    修正案: #1055 を script-only Issue にするなら Outcome から「Skill 文書内の削除」を外すべきです。逆に Outcome を維持するなら、Allowed Paths に少なくとも以下を追加する必要があります。

    .claude/skills/pr-review-judge/SKILL.md
    .claude/skills/pr-review-judge/references/ci-verdict-summary.md
    .claude/agents/pr-reviewer-lite.md
    .claude/agents/pr-reviewer.md
    

    ただし agent 定義まで触るなら scope が拡大します。安全なのは、#1055 を wait_pr_checks.py + tests のみに絞り、Skill/agent 文書置換を follow-up Issue に分けることです。


    2. wait_pr_checks.py は既存 ci_verdict_summary.py / wait_ci_checks.py と統合方針を明記しないと危険

    pr-review-judge/SKILL.md は既に CI 証拠として ci_verdict_summary.py を使い、raw gh pr checks を原則不使用にしています。exit code も 0/10/20/30/40 で all_pass / failed / pending_or_queued / stale_head_sha / gh_error に整理済みです。

    ci_verdict_summary.py は CI_VERDICT_SUMMARY_V1 を出力し、bucket/name/state/workflow/link/event/startedAt/completedAt を取得して、pending、failed、stale、excluded を分類します。

    さらに impl-review-loop/scripts/wait_ci_checks.py は既に gh pr checks --required --json ... を polling し、CI_WAIT_RESULT_V1_JSON= を出力しています。pending なら sleep して再試行し、pass/fail/cancel/skipping/no_checks/head_sha_changed などを返します。

    したがって #1055 の新規 script は、以下のどちらかを明記すべきです。

    Option A:
      wait_pr_checks.py は ci_verdict_summary.py の check classification を再利用し、
      bounded polling と PR_CHECKS_WAIT_RESULT_V1 への変換だけを担当する。
    
    Option B:
      wait_pr_checks.py は wait_ci_checks.py の pr-review-judge 版として実装するが、
      bucket/status/conclusion mapping は ci_verdict_summary.py と同値に保つ。
    

    現状の Issue はこの統合方針がなく、PR_CHECKS_WAIT_RESULT_V1 という第三の schema を追加するだけに見えます。これは「決定論的統一」ではなく、決定論的に見える分岐増加です。


    3. GitHub check の状態空間を過小評価している

    GitHub CLI の gh pr checks は bucket として pass / fail / pending / skipping / cancel を返し、--required、--watch、--interval、--json などを持ちます。(GitHub CLI) しかし GitHub Checks API 側の check run は queued / in_progress / completed / waiting / requested / pending といった status と、action_required / cancelled / failure / neutral / success / skipped / stale / timed_out といった conclusion を持ちます。(GitHub Docs)

    #1055 の AC は pending と failed_blocking_count しか要求していませんが、このままだと skipped、neutral、cancelled、timed_out、action_required、stale の扱いが曖昧です。

    fail-closed の推奨分類:

    success:
      decision_effect: pass_candidate
    
    queued | in_progress | waiting | requested | pending:
      decision_effect: pending
    
    failure | timed_out | action_required | stale:
      decision_effect: failed_blocking
    
    cancelled:
      decision_effect: failed_blocking
    
    neutral | skipped:
      decision_effect: failed_blocking
      exception: 明示された non_blocking rule に一致する場合のみ non_blocking

    特に skipped や neutral を pass 扱いにするのは危険です。GitHub Actions の conditional job では意図的 skip もありますが、merge proof としては「実行された成功」ではありません。例外にするなら (workflow, name) の完全一致 allowlist が必要です。


    4. --required と non-blocking deploy-pr の関係が曖昧

    #1055 は「non-blocking check の設定化(deploy-pr など既知例外)」を In Scope にしています。 しかし gh pr checks --required を使うなら、原則として non-required な deploy-pr は最初から対象外です。逆に all checks を見るなら、required と non-required を混在させるため、deploy-pr などの例外設定が必須になります。

    ここが未定義だと、実装者は次のどちらかに倒れます。

    悪い実装 A:
      --required を使うのに deploy-pr allowlist も持つ。
      → 設定が実質 dead code になる。
    
    悪い実装 B:
      all checks を待つ。
      → deploy / pages / cleanup / retrospective checks で timeout しやすくなる。
    

    推奨: merge 判定の正本は --required のみに寄せるべきです。非 required check は --include-non-required のような明示オプションで追加観測に限定します。

    uv run --locked python3 .claude/skills/pr-review-judge/scripts/wait_pr_checks.py \
      --repo owner/repo \
      --pr 123 \
      --expected-head-sha "$HEAD_SHA" \
      --required \
      --interval-seconds 10 \
      --timeout-seconds 900

    GitHub の branch protection でも required status checks / check runs は保護ルール側で扱われるため、merge blocker として見るべき対象は required checks です。(GitHub Docs)


    5. timeout 時に最後の観測結果を捨ててはいけない

    既存 wait_ci_checks.py は timeout 時に checks=[] を返しています。 #1055 の AC2 は checks[] / pending_count / failed_blocking_count を要求しているため、この挙動をコピーすると timeout の原因調査ができません。

    wait_pr_checks.py では timeout 時にも最後に観測した check 一覧を保持すべきです。

    decision: human_judgment
    pending_count: 2
    failed_blocking_count: 0
    checks:
      - name: python-test
        workflow: CI
        bucket: pending
        state: in_progress
        blocking: true
      - name: deploy-pr
        workflow: deploy
        bucket: pending
        blocking: false
        non_blocking_reason: configured_non_blocking
    poll:
      attempts: 12
      elapsed_seconds: 900
      timed_out: true

    また sleep は time.monotonic() ベースにし、最後の sleep が timeout を超えないように min(interval, deadline - now) を使うべきです。subprocess.run(..., timeout=...) は timeout 時に子プロセスを kill して待機した後 TimeoutExpired を再送出するため、gh_timeout と pending_timeout は別の error code に分けるべきです。(Python documentation)


    6. --pr N だけでは deterministic ではない

    #1055 の Outcome は wait_pr_checks.py --pr N を要求していますが、これだけでは deterministic ではありません。repo と expected head SHA が暗黙になります。

    既存 ci_verdict_summary.py は --repo と --expected-head-sha を必須にしています。 既存 wait_ci_checks.py も --repo、--pr、--head-sha を要求し、head SHA が変わった場合は head_sha_changed を返します。

    #1055 でも最低限これは必要です。

    wait_pr_checks.py \
      --repo owner/repo \
      --pr 123 \
      --expected-head-sha "$HEAD_SHA"

    --pr N のみを許す場合は、repo は gh repo view --json nameWithOwner などから derive し、expected head SHA は script 内で取得して output に明示する必要があります。ただし review judge の stale 判定を強くするなら、呼び出し元が取得した reviewed_head_sha を渡す方が安全です。


    7. pre-existing 判定は wait_pr_checks.py の責務ではない

    #1055 は goal に「pre-existing issue 判定」を含めています。 しかし、pre-existing / out-of-scope failure は #1115 で既に別責務として設計・実装されています。#1115 は、prose による pre-existing 判断をやめ、VC_ADJUDICATION_RESULT_V1 を routing 正本にする Issue でした。

    実装済み adjudicate_vc_result.py は、pytest exit code 5 を regression 扱いせず indeterminate にし、同一 command_hash + 同一 failure_keys + complete evidence + no diff の場合だけ pre_existing_fail を non-blocking にしています。 out-of-scope も failure key が scope と無関係で baseline に存在する場合だけ non-blocking になります。 テストでも no-diff baseline match、new unrelated failure、unsupported failure key、exit code 5 が固定されています。

    したがって #1055 の wait script は、pre-existing を次のように扱うべきです。

    wait_pr_checks.py:
      owns:
        - PR checks の polling
        - pending timeout
        - required/non-blocking check classification
        - PR_CHECKS_WAIT_RESULT_V1 の出力
    
      does_not_own:
        - pytest failure の pre_existing 判定
        - out_of_scope failure 判定
        - baseline/current/diff/failure_key adjudication
    
      may_consume:
        - VC_ADJUDICATION_RESULT_V1

    CLI としては、必要ならこうです。

    wait_pr_checks.py \
      --repo owner/repo \
      --pr 123 \
      --expected-head-sha "$HEAD_SHA" \
      --vc-adjudication-file artifacts/vc-adjudication-result.json

    VC_ADJUDICATION_RESULT_V1 が欠落・stale・blocking の場合は、wait script 側で勝手に non-blocking にせず、decision: human_judgment または decision: failed_blocking に倒すべきです。pytest exit code 5 は公式にも “No tests were collected” であり、テスト失敗や pre-existing failure と同一視してはいけません。(pytestドキュメント)


    推奨する PR_CHECKS_WAIT_RESULT_V1 schema

    #1055 の AC は最低限すぎるため、実装前に schema を固定した方がよいです。

    PR_CHECKS_WAIT_RESULT_V1:
      schema: PR_CHECKS_WAIT_RESULT_V1
      schema_version: 1
      generated_at: "2026-06-30T00:00:00Z"
    
      repo: "owner/repo"
      pr: 123
      expected_head_sha: "<sha>"
      current_head_sha: "<sha>"
      head_sha_status: same | changed | unavailable
    
      decision:
        pass |
        failed_blocking |
        human_judgment |
        stale_head_sha |
        gh_error |
        no_required_evidence
    
      required_only: true
      pending_count: 0
      failed_blocking_count: 0
      non_blocking_failed_count: 0
      excluded_non_blocking_count: 0
    
      checks:
        - name: "python-test"
          workflow: "CI"
          bucket: pass | fail | pending | skipping | cancel | unknown
          state: "success"
          status: completed | queued | in_progress | waiting | requested | pending | unknown
          conclusion: success | failure | cancelled | skipped | neutral | timed_out | action_required | stale | null
          blocking: true
          non_blocking_reason: null
          details_url: "..."
          started_at: "..."
          completed_at: "..."
    
      poll:
        interval_seconds: 10
        timeout_seconds: 900
        attempts: 4
        elapsed_seconds: 31
        timed_out: false
        last_observed_at: "2026-06-30T00:00:31Z"
    
      errors: []
      next_action:
        none |
        inspect_failed_checks |
        wait_or_rerun |
        refresh_head_sha |
        manual_review_gh_error

    decision の precedence は次でよいです。

    1. head SHA changed                    → stale_head_sha
    2. gh command / auth / rate limit error → gh_error
    3. timeout with pending                 → human_judgment
    4. no required check evidence           → no_required_evidence
    5. failed blocking checks               → failed_blocking
    6. all blocking checks pass             → pass
    

    実装上の品質基準

    subprocess

    gh 呼び出しは既存 wait_ci_checks.py と同じく shell=False の exact argv で実行し、GH_PROMPT_DISABLED=1 を入れるべきです。既存実装はこの形になっています。

    subprocess.run(
        ["gh", "pr", "checks", str(pr), "--repo", repo, "--required", "--json", fields],
        capture_output=True,
        text=True,
        timeout=60,
        check=False,
        env={**os.environ, "GH_PROMPT_DISABLED": "1"},
    )

    uv run --locked

    検証コマンドは uv run --locked pytest ... に寄せるべきです。uv run は project environment を作成・更新して command を実行し、--locked は lockfile が変わらないこと、また lockfile が古い場合に失敗することを保証します。(Astral Docs)

    uv run --locked pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q

    Skill 文書から呼ぶ場合

    Claude Code skill から bundled script を呼ぶ文脈では、固定相対パスより ${CLAUDE_SKILL_DIR} を使う方が堅いです。Claude Code docs は ${CLAUDE_SKILL_DIR} を SKILL.md がある directory として提供し、scripts/references 参照に使えると説明しています。(Claude Platform Docs)

    uv run --locked python3 "${CLAUDE_SKILL_DIR}/scripts/wait_pr_checks.py" ...

    ただし、この文書修正は #1055 の現 Allowed Paths 外です。ここは Issue contract を直すか follow-up に分けてください。


    追加すべきテスト

    既存 wait_ci_checks.py のテストは、pass、skipped-only、cancelled、auth error、pending→fail、head SHA changed、no checks を持っています。 #1055 ではこれに加えて、以下を必須にすべきです。

    test_outputs_pr_checks_wait_result_v1_marker_or_json
    test_pending_then_pass_returns_pass
    test_pending_then_fail_returns_failed_blocking
    test_timeout_returns_human_judgment_and_preserves_last_checks
    test_timeout_does_not_oversleep_past_deadline
    test_head_sha_changed_before_poll_is_stale_head_sha
    test_head_sha_changed_after_checks_complete_is_stale_head_sha
    test_no_required_checks_is_no_required_evidence_not_pass
    test_skipped_required_check_is_failed_blocking
    test_neutral_required_check_is_failed_blocking
    test_cancelled_required_check_is_failed_blocking
    test_non_blocking_deploy_pr_is_reported_but_not_blocking
    test_non_blocking_match_requires_exact_workflow_and_name
    test_malformed_gh_json_returns_gh_error_machine_json
    test_gh_not_found_returns_gh_error_machine_json
    test_auth_error_is_classified
    test_rate_limit_error_is_classified
    test_subprocess_timeout_is_gh_timeout_not_pending_timeout
    test_vc_adjudication_blocking_prevents_pass
    test_vc_adjudication_missing_does_not_invent_pre_existing
    

    特に「no checks を pass にしない」テストは重要です。既存 ci_verdict_summary.py には、フィルタなしで checks が 0 件の場合に all_pass とするコメント付き分岐があります。 これは #1055 でコピーしてはいけません。merge proof がない状態は no_required_evidence または human_judgment です。


    Issue 本文の修正案

    #1055 はこの程度まで契約を締めた方がよいです。

    ## Contract Clarification
    
    `wait_pr_checks.py` は PR checks の bounded polling と
    `PR_CHECKS_WAIT_RESULT_V1` 出力のみを担当する。
    
    pre-existing / out-of-scope failure の裁定は
    `VC_ADJUDICATION_RESULT_V1` の責務であり、本 script は
    それを入力として消費する場合のみ参照する。
    本 script は pytest failure / baseline failure を独自判定しない。
    
    ## CLI
    
    ```bash
    uv run --locked python3 .claude/skills/pr-review-judge/scripts/wait_pr_checks.py \
      --repo <owner>/<repo> \
      --pr <PR> \
      --expected-head-sha "$HEAD_SHA" \
      --required \
      --interval-seconds 10 \
      --timeout-seconds 900

    Optional:

      --include-non-required \
      --non-blocking-check deploy-pr \
      --vc-adjudication-file artifacts/vc-adjudication-result.json

    Decision Rules

    • success の blocking check のみ pass evidence とする。
    • queued/in_progress/waiting/requested/pending は pending。
    • failure/timed_out/action_required/stale/cancelled は failed_blocking。
    • neutral/skipped は failed_blocking。ただし exact non-blocking rule 一致時のみ non-blocking。
    • timeout 時は decision: human_judgment とし、最後に観測した checks[] を必ず出力する。
    • head SHA mismatch は stale_head_sha で fail-closed。
    • required check が 0 件の場合は no_required_evidence。pass にしない。
    
    ---
    
    ## 最終判断
    
    #1055 は実装着手前に contract を締め直すべきです。現状のまま実装すると、表面上は `wait_pr_checks.py` が追加されても、実際には次の false-green が残ります。
    
    ```text
    - Allowed Paths 外の文書置換が必要なのに script/test だけで完了扱いになる
    - ci_verdict_summary.py / wait_ci_checks.py と異なる bucket 判定になる
    - deploy-pr 例外が required-only 実行では dead code になる
    - timeout 時の pending 実体が checks[] から消える
    - no checks が pass 扱いされる
    - pre-existing 判定が #1115 の VC_ADJUDICATION_RESULT_V1 と競合する
    

    実装方針としては、wait_pr_checks.py を “polling normalizer” に限定し、pre-existing は VC_ADJUDICATION_RESULT_V1 の消費だけにするのが最も安全です。Skill/agent 文書から raw gh pr checks を排除する作業は、Allowed Paths を拡張するか、別 Issue に分割してください。


    you asked

    message time: 2026-07-01 02:23:32

    動作検証は作業内容に含まれているか?実際にスクリプトがCI完了を待機できるか。ClaudeCodeやCodexCLIなどのAIエージェントにとって適切なスクリプトになっているか動作確認することは含まれている?。


    chatgpt response

    いいえ。#1055 の現 Issue 定義だけでは、実CIで「pending → pass/fail まで実際に待機できるか」の動作検証は十分に含まれていません。

    含まれているのは主に次です。

    • wait_pr_checks.py の追加
    • PR_CHECKS_WAIT_RESULT_V1 の出力
    • pending がある場合の bounded polling
    • timeout 時の human_judgment
    • non-blocking check の設定化
    • uv run pytest .claude/skills/pr-review-judge/tests/test_wait_pr_checks.py -q の unit test 実行

    つまり、unit test レベルの検証は含まれているが、GitHub 上の実PRに対して gh pr checks を叩き、実際にCI完了を待てるか確認する integration / smoke test は明示されていません。

    現状の不足

    #1055 の Verification Commands は、test -f、rg、uv run pytest ... が中心です。これは「実装物が存在する」「文字列がある」「単体テストが通る」の確認であって、次は検証していません。

    - 実PRで pending の check を観測できるか
    - pending 中に polling し続けるか
    - CI 完了後に pass / failed_blocking へ正しく遷移するか
    - timeout 時に最後の checks[] を保持するか
    - head SHA が途中で変わった場合に stale として止まるか
    - gh auth / permission / rate limit / malformed JSON 時に agent が読める machine output を返すか
    - Claude Code / Codex CLI が sleep shell loop を組まずにこの script を使える導線になっているか
    

    特に AI エージェント向けの適切性は、現状だと弱いです。pr-review-judge/SKILL.md は既に ci_verdict_summary.py を使い raw gh pr checks を原則不使用にすると書いていますが、#1055 の Allowed Paths には Skill 文書更新が含まれていません。 さらに pr-reviewer-lite.md にはまだ raw gh pr checks <PR番号> を直接使う Gate が残っています。

    そのため、「AIエージェントが適切に使えるスクリプトになっているか」の確認は、Issue の目的には近いが、作業内容としては未固定です。

    含めるべき追加AC

    #1055 には最低限、次を追加すべきです。

    - [ ] AC7: 実PRまたは fixture-backed smoke で、pending → pass/fail の polling 遷移を確認する
    - [ ] AC8: timeout 時に `decision: human_judgment` と最後の `checks[]` を出力する
    - [ ] AC9: `--repo` / `--pr` / `--expected-head-sha` 指定で head SHA drift を fail-closed できる
    - [ ] AC10: Claude Code / Codex CLI が shell sleep loop を組まずに呼べる usage example を固定する
    - [ ] AC11: `pr-reviewer-lite` など raw `gh pr checks` 経路が残る場合は follow-up issue を作る

    追加すべき検証コマンド

    実CIを使うなら、検証コマンドはこの形が必要です。

    HEAD_SHA=$(gh pr view <PR> --repo squne121/loop-protocol --json headRefOid --jq .headRefOid)
    
    uv run --locked python3 .claude/skills/pr-review-judge/scripts/wait_pr_checks.py \
      --repo squne121/loop-protocol \
      --pr <PR> \
      --expected-head-sha "$HEAD_SHA" \
      --required \
      --interval-seconds 10 \
      --timeout-seconds 900

    ただし、常に pending PR を用意できるとは限らないため、unit test だけでなく fake gh fixture による integration-style test も入れるのが現実的です。

    test_fake_gh_pending_then_pass_returns_pass
    test_fake_gh_pending_then_fail_returns_failed_blocking
    test_fake_gh_pending_until_timeout_returns_human_judgment
    test_fake_gh_head_sha_changes_during_wait_returns_stale_head_sha
    

    判断

    現状の #1055 は、「スクリプトを書くこと」と「単体テストで polling ロジックを確認すること」は含んでいるが、あなたが聞いている次の観点は 明示的には含まれていません。

    実際にCI完了を待機できるか
    Claude Code / Codex CLI が安全・決定論的に使えるか
    raw gh pr checks / shell sleep loop の実利用経路が置換されたか
    

    したがって、#1055 は実装前に Runtime / Agent Usability Verification を AC と Verification Commands に追加するべきです。現契約のままだと、スクリプトは追加されたが実運用で使われない、または pr-reviewer-lite が raw gh pr checks を使い続ける false completion になり得ます。

  3. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-30T17:33:42Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1055
      body_sha256: "sha256:a8220a9e2b046c9bcc3cd4329ed5c2590c1d8ddb43da771e64d44fb60bec80ac"
      checks:
        template_compliance: pass
        state_label: pass
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        ac_verifiability: pass
        product_spec_check: pass
        worktree_branch_collision: pass
        vc_preflight:
          status: pass
        next_action: implement_issue
        blocked_reasons: []
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "Current Validated Scope と In Scope の語彙差分 warning はあるが、deterministic blocker ではない"
  4. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    anchor comment https://github.com/squne121/loop-protocol/issues/1055#issuecomment-4846148706 を一次ソースとして本文を comment-first で再構成し、script-only scope に正規化しました。Allowed Paths と Outcome の矛盾を除去し、pre-existing / out_of_scope 裁定を既存責務へ戻し、baseline 実装前でも deterministic に通る Verification Commands / Runtime Verification Applicability を付与しています。

    最終確認では check_issue_contract.py が approve、contract_readiness_check.py --mode preflight-static が status: go、run_contract_review_once.py が fresh go comment を検出しました。

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1055#issuecomment-4846257932
        generated_at: "2026-06-30T17:33:42Z"
        body_sha256: "sha256:a8220a9e2b046c9bcc3cd4329ed5c2590c1d8ddb43da771e64d44fb60bec80ac"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-06-30T17:33:42Z"
      checked_body_sha256: "sha256:a8220a9e2b046c9bcc3cd4329ed5c2590c1d8ddb43da771e64d44fb60bec80ac"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
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