abbc02.org
「I Built gh-lookout to Wait for GitHub Actions CI Without Hitting API Limits」の abbc02.org です。「そのまま開く」はファイルをそのまま返します。
* I Built gh-lookout to Wait for GitHub Actions CI Without Hitting API Limits
:properties:
:export_file_name: generated/contents/blog/2026/abbc02
:export_date: 2026-12-06 00:15
:export_updated: 2026-12-06 00:30
:export_lang: en
:export_original: /blog/2026/bc0993
:export_tags: rust lean github-actions ci ai-agent cloudflare formal-verification release gh-lookout lean-leanfran lean-leanassay
:end:
Multiple AI agents working in parallel stack up =gh run watch= calls after each push.
As shown in its [[https://github.com/cli/cli/blob/v2.105.0/pkg/cmd/run/watch/watch.go#L231-L241][source]], =gh run watch= makes two API requests at 3-second intervals by default, consuming 2,400 requests per hour per agent.
Three agents waiting at once reach 7,200 requests per hour, passing the [[https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api][5,000-request hourly REST API limit]] for signed-in users.
I built gh-lookout, a =gh= extension that receives GitHub webhooks on the public service [[https://lookout.conao3.com/][lookout.conao3.com]] and notifies your CLI.
You run no local daemon and make zero API requests while waiting.
Even on external open-source repositories where you cannot install the GitHub App, the same =gh lookout wait= command works.
The source lives at [[https://github.com/conao3/gh-lookout][conao3/gh-lookout]] under the [[https://github.com/conao3/gh-lookout/blob/v0.2.0/LICENSE][Apache-2.0]] license.
This post walks through usage and architecture based on [[https://github.com/conao3/gh-lookout/releases/tag/v0.2.0][v0.2.0]].
[[github:conao3/gh-lookout::Rust][Wait for GitHub Actions from the command line]]
** Zero API Requests While Waiting
Three agents waiting for CI for one hour make 7,200 REST API requests with =gh run watch= versus 0 with =gh lookout wait=.
The chart below comes from the [[https://lookout.conao3.com/][lookout.conao3.com]] home page.
[[./resources/public/img/bc0993-relay-chart.png]]
gh-lookout runs on three parts: GitHub, the hosted service [[https://lookout.conao3.com/][lookout.conao3.com]], and the local =gh lookout= CLI.
[[./resources/public/img/abbc02-architecture.svg]]
** Usage
Install gh-lookout as a =gh= CLI extension.
On Nix, you can also run =nix run github:conao3/gh-lookout -- --help=.
#+begin_src sh
gh extension install conao3/gh-lookout
gh lookout login
#+end_src
Running =gh lookout login= prints a URL and verification code for you to approve in your browser.
Because authentication opens no local port, it works over SSH sessions and inside containers.
For your own repositories or organizations, install the public [[https://github.com/apps/gh-lookout/installations/new][gh-lookout]] GitHub App on that account.
After that, pass a repository and commit SHA to wait.
#+begin_src sh
gh lookout wait conao3/gh-lookout 5f15b63
#+end_src
Once CI finishes, the command prints each workflow's conclusion and URL.
#+begin_example
conao3/gh-lookout 5f15b63 success
CI success https://github.com/conao3/gh-lookout/actions/runs/47608418024
#+end_example
The command exits with 0 if all workflows pass, 1 on failure, and 3 when the commit has no CI.
Pass =--json= if a script needs structured output.
Run =gh lookout status= to list recent commits.
#+begin_src sh
gh lookout status conao3/gh-lookout
#+end_src
** How It Works
The hosted service [[https://lookout.conao3.com/][lookout.conao3.com]] runs on Cloudflare Workers and Durable Objects.
For repositories with the public [[https://github.com/apps/gh-lookout][gh-lookout]] GitHub App installed, Lookout receives =workflow_run= webhooks from GitHub and saves the run state.
Lookout tracks commits by SHA instead of pull requests, so direct pushes to =master= work the same way.
Running =gh lookout wait= opens a WebSocket connection that sleeps through the Durable Objects WebSocket Hibernation API.
Idle connections incur zero duration charges and wake the moment the next webhook arrives.
If a network blip drops the socket, the CLI reconnects with the remaining timeout.
Before returning results for a private repository, Lookout verifies read access with your GitHub OAuth token so unauthorized accounts see nothing.
** External OSS Repositories
You can install the GitHub App on your own account, not on third-party open-source repositories where you contribute.
gh-lookout detects whether the App is installed on the target repository and switches uninstalled public repositories to server-side polling.
#+begin_src sh
gh lookout wait clojure-lsp/clojure-lsp 2ecf241
#+end_src
#+begin_example
clojure-lsp/clojure-lsp 2ecf241 success
CI success https://github.com/clojure-lsp/clojure-lsp/actions/runs/47556737140
#+end_example
Server-side polling keeps rate-limit usage low:
- Concurrent clients waiting on the same commit share a single server-side poll loop.
- Lookout caches each response =ETag= so =304 Not Modified= replies consume no rate limit.
- The poll interval steps through 15, 30, and 60 seconds and stops as soon as the last waiting CLI disconnects.
Requests use the waiting user's own GitHub OAuth token, covering public repositories.
Uninstalled private repositories remain inaccessible.
Pull requests from external forks can pause in =action_required= pending maintainer approval.
Upon seeing that state, gh-lookout returns exit code 5 instead of waiting for timeout.
After a maintainer approves the run, running =gh lookout wait= again fetches fresh state and resumes normal waiting.
** Commit Verdicts in Lean 4
Deciding commit completion across parallel workflows involves several overlapping rules.
You must ignore older rerun attempts, distinguish running jobs from approval waits, and wait 30 seconds after a workflow finishes for follow-up runs to start.
I wrote the three core functions in Lean 4 in [[https://github.com/conao3/gh-lookout/blob/v0.2.0/lean/Lookout/Model.lean][lean/Lookout/Model.lean]] and compiled them to TypeScript for the Cloudflare Worker with [[/blog/2026/21ebbd][leanfran]].
- =latest= keeps the newest attempt for each run ID.
- =verdict= computes pending, succeeded, failed, action-required, or no-CI from the latest attempts and elapsed time.
- =passedConclusion= treats =success=, =skipped=, and =neutral= as passing.
The =verdict= function takes this form:
#+begin_src lean
def verdict (runs : List Run) (now waitStart lastEvent settle noCiAfter : Nat) : Verdict :=
let rs := latest runs
if rs.isEmpty then
if waitStart + noCiAfter ≤ now then .noCi else .pending
else if !(rs.all (fun r => r.completed || r.actionRequired)) then .pending
else if rs.any (·.actionRequired) then .actionRequired
else if now < lastEvent + settle then .pending
else if rs.all (·.passed) then .succeeded
else .failed
#+end_src
I proved specification theorems for each of the three functions and audited them with mutation testing in [[/blog/2026/e3d3ca][leanassay]].
In =v0.2.0=, the theorems killed all 31 non-equivalent mutants out of 36 generated (5 equivalent, 0 holes).
Lean 4 proves the decision logic that turns collected runs into a commit verdict.
TypeScript and Rust handle Durable Object storage, WebSockets, GitHub API calls, and CLI reconnection, verified by unit and integration tests.
** Pricing and Scope
The hosted service [[https://lookout.conao3.com/][lookout.conao3.com]] gives each account 500 completed runs per week for free without delay.
Lookout counts completed runs that you wait on and avoids double-counting repeated waits on the same attempt.
To help cover Cloudflare Workers costs, I cap the free tier and invite support through [[https://github.com/sponsors/conao3][GitHub Sponsors]].
Runs beyond 500 in a week arrive 10 minutes late until the Monday 00:00 UTC reset, while sponsor accounts have no delay.
gh-lookout targets GitHub Actions =workflow_run= events, so repositories using external CI such as CircleCI or Buildkite report no CI.
Private repositories require installing the [[https://github.com/apps/gh-lookout][gh-lookout GitHub App]].
Command flags and account management are in the [[https://github.com/conao3/gh-lookout][README]] and on your [[https://lookout.conao3.com/account][account page]].