Files
PaperClipAI/scripts
DottaandClaude Opus 5.5 7b4f4c81e0 fix(ci): make unchanged GitHub Actions polls free with conditional requests (#22677)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - CI on master builds the Docker image that deploys staging. The
release and readiness watchers in those workflows poll the GitHub
Actions API every 30 seconds, for up to 40 or 90 minutes.
> - The watchers use the workflow `GITHUB_TOKEN`. On the GitHub Team
plan, that token has one shared quota of 1,000 requests per hour for all
jobs in this repository.
> - One release watcher poll makes about 8–13 reads, so one watcher can
use most of the hour's quota. On busy days the quota runs out, and
unrelated calls fail with "API rate limit exceeded for installation". On
2026-11-23 this failed `docker/metadata-action` in two Docker builds,
and staging did not deploy for hours.
> - Most of these reads return the same data as the last poll. GitHub
does not count a `304 Not Modified` response against the quota.
> - This pull request makes the shared Actions reader send the last ETag
for each path and reuse the cached body on a 304.
> - The benefit is that an unchanged poll costs nothing. The watchers
use about 80% less quota, and the poll interval stays the same, so
releases are not slower.

## Linked Issues or Issue Description

**What happened?**
On 2026-11-23, Docker push builds on master failed with `API rate limit
exceeded for installation` in `docker/metadata-action`.
`actions/setup-node` also could not fetch its version manifest. The
repository's shared `GITHUB_TOKEN` quota was exhausted. Staging stayed
on one commit for several hours.

**Expected behavior**
Long-running CI watchers do not use up the repository's shared API
quota, so other jobs can make their API calls.

**Steps to reproduce**
1. Merge several pull requests to master in one hour.
2. Each Docker and readiness run starts watchers
(`scripts/watch-release-source.mjs`,
`scripts/cloud-source-verification.mjs`). Each watcher reads the Actions
API about 8–13 times every 30 seconds.
3. When the hourly quota is used up, other steps that call the API fail.

**Paperclip version or commit**
`master` at 45221a17ea.

## What Changed

- `scripts/github-actions-reader.mjs`: `createActionsReader()` keeps the
last ETag and body for each path. Each read sends `If-None-Match`. On a
304 it returns a copy of the cached body. A 200 replaces the cache
entry, and a 200 without an ETag removes it. Retry, timeout and error
behavior are unchanged.
- `scripts/cloud-source-verification.test.mjs`: tests for the
conditional request, the 304 reuse, cache replacement when the resource
changes, per-path ETags, and that a caller cannot change the cached
body.

All callers of the shared reader get the change:
`watch-release-source.mjs`, `cloud-source-verification.mjs` and
`cloud-release-admission.mjs`. The poll interval is unchanged.

## Verification

- Red/green: before the change, the new test "a repeated read sends its
ETag and reuses the body when GitHub answers 304" failed. After the
change, `node --test scripts/cloud-source-verification.test.mjs` passes
60/60.
- `node --test scripts/cloud-readiness-runner-loss.test.mjs`: 24/24.
`node --test scripts/__tests__/release-verify-workflow.test.mjs`: 73/73.
- Measured against the live GitHub API: I replayed the read-only calls
of one watcher poll (the jobs listing, `readSourceVerification`,
`readMigratorPublication`) every 30 seconds. I counted charged (200) and
free (304) responses:
- Docker build in progress (run 45224519666): 10 polls, 80 reads, **15
charged** and 65 free (81% fewer charged requests).
- Docker build waiting in the queue: 6 polls, 54 reads, **9 charged**
and 45 free (83% fewer).

## Risks

- Low risk. A 304 means that GitHub's data has not changed, so the
reused body is the current answer. The cache lives only for one script
run.
- If GitHub stops sending ETags for an endpoint, the reader makes normal
requests as before.

## Model Used

Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, GitHub CLI).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:35:56 -06:00
..
2026-03-09 10:03:45 -05:00
2026-03-03 14:00:10 -06:00
2026-04-09 06:14:12 -05:00