Commit Graph
3 Commits
Author SHA1 Message Date
Devin FoleyandPaperclip bda1bf7b52 fix(ci): respect GitHub quota resets during image publication (#22690)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Its image workflow builds immutable images and requires proof for
the exact source.
> - GitHub API quota failures can stop metadata generation and
verification reads.
> - Short retries before the quota reset consume requests without
restoring progress.
> - This pull request removes metadata API reads and makes quota retries
respect server timing and job budgets.
> - The benefit is fewer API requests and clear quota errors without
weakening release proof.

## Linked Issues or Issue Description

Refs #22677, which adds conditional requests for unchanged Actions
polls. This change retains that cache and extends quota recovery.

**What happened?**

[Docker run
45215585951](https://github.com/paperclipai/paperclip/actions/runs/45215585951)
failed in both Docker metadata steps with an installation API rate-limit
error. [Run
45210434846](https://github.com/paperclipai/paperclip/actions/runs/45210434846)
built both architectures but failed during source verification reads.
The reader retried quota-proven HTTP 403 responses after seconds and
then failed with a generic HTTP error. It ignored the primary reset time
and could shorten Retry-After below the server requirement.

**Expected behavior**

Metadata generation should need no GitHub API request. Quota recovery
should wait until GitHub permits another request, within the caller
deadline. Exhausted budgets should identify the quota failure and safe
response-header details. Permission failures must remain immediate.
Missing source, migrator, or attestation proof must still block
publication.

**Steps to reproduce**

1. Return HTTP 403 with zero remaining requests and a reset two minutes
away to the Actions reader.
2. Observe the old reader retry after seconds and exhaust its attempts
before the reset.
3. Return an hour-long Retry-After value. Observe the old reader retry
after its one-minute cap.

**Version**

Master after #22677.

**Deployment mode**

GitHub Actions image publication and release verification.

## What Changed

- Honor primary reset times and Retry-After seconds or dates. Use a
minute-long exponential fallback for secondary throttling without timing
headers.
- Bound the entire wait by a per-read budget and the caller deadline.
Keep permission-denied 403s immediate and preserve ETag caching and
transport retries.
- Emit a typed quota error with allowlisted token-source, resource,
limit, remaining, and reset diagnostics. Do not log tokens, response
bodies, or request URLs.
- Share the Docker observer's 40-minute deadline with its reader. Bound
final proof rechecks to five minutes. Add an explicit `github.token`
source hint beside workflow-issued token bindings.
- Generate Docker tags and OCI labels from checkout and workflow inputs.
Keep release-lane and immutable SHA tags. Feed metadata JSON explicitly
to manifest publication. Stop fetching the GitHub repository
description; keep local license and migration labels.
- Add regression tests and run them in the trusted PR and
source-verification workflows. Document retry budgets and metadata
inputs.

## Verification

- Final acceptance: [CI attempt
3](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/3)
succeeded on `302da8c`. All 68 reported checks are complete, with no
pending or failing checks. Greptile reviewed that exact commit at 5/5
and both review threads are resolved. The voice timeout recovered
without code changes; its earlier cause remains unconfirmed. Prior
failures and local reproduction limits remain below.

- [CI attempt
2](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/2)
recovered the interrupted checks. Its only remaining test failure is
server shard 2/12: `voice-session-store.integration.test.ts`, “retains
both spoken sides once on the public call task and preserves
quarantine,” exceeded 15 seconds on both Vitest attempts. The `ci /
verify` failure is its aggregate. The voice test file is byte-identical
to master and absent from this PR diff; its cause is not established as
an infrastructure fault. A focused local attempt could not start
PostgreSQL because the macOS binary lacks `libzstd.1.dylib`; no voice
test passed locally. Requesting one bounded retry of the affected shard
without code changes; all earlier failures remain recorded here.

- The automatic runner-loss retry helper for the current run failed on a
GitHub job-log download with HTTP 503 ([helper run
45265762243](https://github.com/paperclipai/paperclip/actions/runs/45265762243)).
Once the PR workflow completed, a manual failed-job retry was requested
successfully for unchanged head `302da8c`. Retry results remain pending;
no interrupted check is treated as passed.

- [CI run
45263398107](https://github.com/paperclipai/paperclip/actions/runs/45263398107)
on `302da8c` lost 25 jobs during verification. Inspected the logs for
these 25 jobs: all 25 contain an explicit runner shutdown signal
followed by cancellation, with no additional error records. This
includes Rust, browser, general-server, and serialized-server lanes.
These are interrupted checks and remain unverified until retried.
Greptile reviewed this exact commit at 5/5 with no new findings.

- Combined focused release/metadata and PR policy suite: **1,008 tests
passed**, zero failures. Command: `node --test
scripts/github-actions-rate-limit.test.mjs
scripts/docker-image-metadata.test.mjs
scripts/cloud-source-verification.test.mjs
scripts/cloud-readiness-runner-loss.test.mjs
scripts/standard-image-contract.test.mjs
scripts/reuse-canary-image.test.mjs scripts/merge-group-image.test.mjs
scripts/__tests__/release-verify-workflow.test.mjs
.github/scripts/tests/*.test.mjs`.
- `pnpm exec vitest run
server/src/services/online-durable-data-migration.test.ts --project
@paperclipai/server`: **32 tests passed** after incorporating upstream
#22686. The final PR diff includes no migration test or runtime change.
- In `packages/paperclip-runner`, `pnpm exec vitest run
src/drivers/acpx/cursor-mode.test.ts
src/drivers/acpx/grok-native-session-options.test.ts --maxWorkers 1`:
**26 tests passed**. This local pass does not explain the earlier CI
timeouts.
- New tests first reproduced ignored primary reset timing, early
Retry-After retries, missing service-error waits, and older-checkout
failures. CLI tests confirm quota exhaustion produces a safe annotation,
no verified output, and no cancellation request. Workflow tests cover
neither, either, and both new test files being present.
- Initial policy CI failed two assertions that expected the old metadata
action and single-file proof test command. Updated them to check both
local metadata steps, the full-SHA tag, and all proof tests. Initial
Greptile findings about service Retry-After and older checkouts are
fixed and resolved.
- [CI attempt
1](https://github.com/paperclipai/paperclip/actions/runs/45259240827/attempts/1)
lost the Build runner and server shards 1, 7, and 12 within four
seconds. Logs explicitly record shutdown signals followed by
cancellation; Build reported no compiler error. Runner lane 2/3 hit
five-second Cursor and Grok test timeouts. E2E shard 2/8 failed document
visibility after outage/reload and the cached-task 404 assertion. Those
test failures are not assumed to be infrastructure faults. Their
aggregate checks also failed. They remain merge blockers until fresh CI
passes.
- Server shard 9 also found a deterministic, pre-existing
blocker-enumeration test failure. Reproduced it on unchanged base
`427d13c38c63`: the source scanner omitted helper-declared blockers.
Upstream #22686 fixes that test. Incorporated its version when updating
from master and removed the duplicate fix from the final diff. A
failed-job retry was accepted after attempt 1 finished; the updated
branch now needs fresh CI.
- Local setup: filtered frozen-lockfile installation changed no
lockfile. Initial server-test startup lacked built plugin SDK output;
`pnpm --filter @paperclipai/plugin-sdk ensure-build-deps` supplied it
before the passing run. Local tests used macOS and Node 25.6.1; CI
checks Linux and its configured Node version.
- `pnpm verify` initially could not start because the fresh worktree
lacked `cli/node_modules/tsx`. The underlying `node
scripts/local-verify.mjs` returned exit 2: workflow changes require
broad CI. No full local Vitest or Docker build was run. Required CI
supplies broad coverage.
- No credentials were changed and no live publication or deployment was
requested. CI retries do not authorize image publication or bypass
proof.

## Risks

- A reset outside the allowed wait still fails closed. Shared repository
quota pressure from other workflows can still delay publication.
- Attestation and source/migrator proof remain required. This change
does not add a privileged token or bypass a check.
- OCI labels now use checkout inputs. The remote repository description
is omitted; source, revision, version, creation time, license, and
schema labels remain available.
- Revert this PR to restore the previous reader and metadata action. No
database or runtime application changes are required.

## Model Used

OpenAI gpt-6.1-sol with xhigh reasoning, through Codex in T3 Code. Used
code editing, GitHub log and upstream action-source inspection, and
local test execution.

## 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] This is a CI reliability fix; it does not change planned product
scope
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have described the issue in-PR following the bug template
- [x] I have not referenced internal or instance-local issues or links
- [x] My branch name describes the change
- [x] I have run focused tests locally and they pass; the broad
verification limitation is recorded
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation
- [x] I have considered and documented risks
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-23 14:39:14 -08:00
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
DottaandPaperclip 44a4ca1c61 fix(ci): remove the admission CLI import cycle (#18889)
Move the unchanged Actions read transport into an independent module so the admission CLI can evaluate consumers without awaiting a circular import of source verification. Preserve the existing source verification export and all verification and placement contracts.

Five child-process cases reproduce the original exit-13 failure before the repair and pass afterward. All 59 source/admission/image checks and 665 workflow contracts pass. Both CLI modes also pass read-only smoke checks against real GitHub metadata. Complete latest-head CI passed on its first attempt, with Greptile 5/5 and no unresolved comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-03 18:21:55 -06:00