shepherd: read each PR in one GraphQL query, conditional REST for the rest, cache what a finished SHA can't change (Part of promoter-bot#64)

クローズ
#6,534 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, python
領域
api, devtools

調査の方向性

Start with tests/tools/shepherd_gh.py and trace gather() plus the reused ci_digest.py and pr_check.py reads. Compare the REST snapshot with a fake GraphQL response, then check that decide() makes the same decisions and measure REST calls and GraphQL points across the recorded PR snapshot. Done means the REST fallback and cache behavior work, the stated quota reduction is measured, and shepherd-*.yml remains unchanged.

索引モデルが issue の本文から書いたものです。

説明

ci-cd enhancement github-actions priority: high scope:infra

Part of squid-protocol/promoter-bot#64. Owner 2026-10-24: the GitHub API quota is halting work.

Why

tests/tools/shepherd_gh.py runs on AUTOMATION_PAT, so it shares the account's 5,000/h REST quota with the agent fleet and the owner's sessions. On 2026-10-24 it failed 25 times when that quota ran out, 20 of them in two blackouts, and nothing merged meanwhile. The fleet's measured burn is ~3,400/h.

A full reconcile pass costs ~8–14 REST calls per labelled PR (~20 PRs), from gather():

  • pulls/N
  • issues/N/comments, paged
  • commits/SHA/check-runs, paged
  • commits/SHA/status
  • issues/N/events, paged
  • head_pushed_at (check-suites), paged
  • commits/SHA parents
  • actions/runs/ID attempts

gitgalaxy#6529 already memoises user and the permission reads within a pass.

Change (keep decide() and every rule unchanged)

  1. GraphQL for the per-PR snapshot (separate 5,000-points/h quota). One query per PR, or per batch of PRs in a reconcile pass, gets:

    • the PR's state, head SHA and labels
    • comments (author login + body, for the approval markers)
    • the head commit's statusCheckRollup contexts (check runs and statuses: name, status, conclusion, workflow run database id)
    • the labeled events (timelineItems(itemTypes: [LABELED_EVENT]) with actor and createdAt)
    • the head commit's pushedDate, or its committedDate if that's absent

    Map them into the exact dict gather() builds today, and fall back to the REST path when GraphQL fails.

  2. Conditional requests for the REST reads that stay: send the cached ETag as If-None-Match; a 304 doesn't count against the quota. Cache under the runner's flake-cache directory, or $RUNNER_TEMP within a pass.

  3. Cache what can't change:

    • check runs and statuses of a SHA whose checks are all completed
    • commit parents
    • an actions/runs/ID that's completed

    Cache by key within the reconcile pass, and across passes through the existing flake-cache save if it fits.

Acceptance

  • A test with a fake GraphQL response checks that gather() returns the same dict the REST path did for the same PR state, and that decide() makes identical decisions on it.
  • The PR body states the REST calls per full reconcile pass, before and after, measured with a counting fake api over a recorded snapshot of the ~20 labelled PRs, and the GraphQL points it adds.
  • shepherd-*.yml is unchanged (those still need the owner's per-PR OK).

Class / sibling gaps

ci_digest.py and pr_check.py (reused by the shepherd) make the same per-PR check-run reads. Apply the same GraphQL or cache path where the shepherd calls them.

主要言語
Python
スター
57
フォーク
11
平均マージ
1時間 21分
マージ済み PR(30日)
971

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

squid-protocol/gitgalaxy のほかの issue

squid-protocol/gitgalaxy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。