Files
PaperClipAI/scripts
Dotta 880b0c3a7c perf(ci): reuse verified macOS runtime artifacts from master runs cancelled downstream (#23044)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - `docker.yml` and `docker-merge-group.yml` bundle the native macOS
SSH runtime produced by `macos-runner-runtime.yml`, reusing a cached
artifact by inputs digest when possible
> - `scripts/macos-runner-runtime-cache.mjs` only reused an artifact
when the entire `docker.yml` run concluded `success`
> - Whenever a `master` `docker.yml` run was cancelled downstream (e.g.,
on a flaky post-merge test shard) after both `macos_runner_runtime /
build` and `verify_linux_controller` already passed, the next build
threw away the verified artifact and rebuilt from scratch for ~9.5
minutes on `macos-15` before `build-and-push` could start
> - This pull request checks job-level verification
(`macos_runner_runtime / build` and `macos_runner_runtime /
verify_linux_controller` both `completed` + `success`) on trusted
`master` `docker.yml` runs when the overall run did not conclude
`success`
> - The benefit is that `macos_runner_runtime` stays on its ~1m
cache-hit path instead of repeatedly burning ~9.5m on the `docker.yml`
critical path

## Linked Issues or Issue Description

**What happened?**
`scripts/macos-runner-runtime-cache.mjs` discards already-verified macOS
runtime artifacts from `master` `docker.yml` runs whenever the workflow
is cancelled or fails downstream, causing repeated ~9.5m `macos-15`
rebuilds before `build-and-push` can begin.

**Expected behavior**
Keep the exact trust boundary (`paperclipai/paperclip`,
`.github/workflows/docker.yml`, `event === "push"`, `head_branch ===
"master"`, 40-hex `head_sha`) and reuse the verified artifact either
when the overall run concluded `success` (fast path) or when both
`macos_runner_runtime / build` and `macos_runner_runtime /
verify_linux_controller` concluded `success` in that run.

**Steps to reproduce**
1. Merge a commit to `master` where `macos_runner_runtime / build` and
`macos_runner_runtime / verify_linux_controller` succeed, then an
unrelated downstream check cancels `docker.yml`.
2. Merge the next commit with identical Runner inputs.
3. Observe `Find an identical runtime from a successful master image
build` miss and rebuild the macOS binary and provider pack from scratch
on `macos-15`.

## What Changed

- `scripts/macos-runner-runtime-cache.mjs`: add
`isTrustedMacRuntimeWorkflowRun` and `hasVerifiedMacRuntimeJobs`, check
job-level success on trusted `master` `docker.yml` runs whose overall
conclusion is not `success`, and inspect up to 10 unexpired matching
artifacts.
- `scripts/macos-runner-runtime-cache.test.mjs`: add unit tests
verifying reuse from a master run cancelled downstream when both macOS
jobs succeeded and rejection when either job is incomplete, cancelled,
or failed.

## Verification

- `node --test scripts/macos-runner-runtime-cache.test.mjs
scripts/macos-runner-runtime.test.mjs`: 12/12 passed.

## Risks

- Low risk. Trust boundary stays strictly restricted to canonical
`master` `push` runs of `.github/workflows/docker.yml`, requires both
the macOS build/qualification job and Linux controller verification job
to have succeeded, and the consuming run still verifies the downloaded
artifact in `verify_linux_controller`.

## Model Used

- Google Antigravity agent (Gemini / Antigravity coding harness with
shell execution and tool use).

## 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
- [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
2026-11-26 07:22:17 -06:00
..
…