mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
perf(docker): consume attested Runner image in merge-queue builds and promote on master (#22993)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The repository includes `.github/workflows/docker-merge-group.yml` and `scripts/merge-group-image.mjs` to pre-build production images in the GitHub merge queue so `.github/workflows/docker.yml` can promote verified bytes on `master` instead of rebuilding from scratch > - Currently, `docker.yml` skips merge-queue promotion whenever `needs.runner_image.outputs.mode == 'published'`, and `docker-merge-group.yml` builds the Runner inline on 4-core `ubuntu-latest` while waiting up to 15 minutes during promotion lookup > - With `RUNNER_IMAGE_CONSUME_ENABLED=true`, that meant enabling the merge queue would never promote pre-built images on normal commits > - This pull request wires read-only attested Runner image consumption into `docker-merge-group.yml`, records and verifies `runnerInputsDigest` in `scripts/merge-group-image.mjs`, routes canonical `amd64` merge-group builds to `cloud-release-32`, parallelizes disk cleanup, caps promotion wait to 3 minutes, and allows `docker.yml` to promote verified merge-queue images when `runner_image` resolves to `published` > - The benefit is enabling fast pre-merge image promotion for merge-queue commits without weakening attestation, Runner-digest matching, or credential isolation ## Linked Issues or Issue Description **What existing behavior does this improve?** Pre-merge Docker image building and promotion across `.github/workflows/docker-merge-group.yml`, `scripts/merge-group-image.mjs`, and `.github/workflows/docker.yml`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** `docker-merge-group.yml` builds the Runner inline on `ubuntu-latest` with serial disk cleanup, and `docker.yml` disables merge-queue promotion whenever `needs.runner_image.outputs.mode == 'published'`. `scripts/merge-group-image.mjs` also waits up to 15 minutes for an in-flight merge-group run. **Proposed behavior** `docker-merge-group.yml` resolves an already-published Runner image (non-blocking lookup, read-only permissions, `gh attestation verify`), runs `amd64` on `vars.CORE_PUBLICATION_RUNNER || 'cloud-release-32'`, skips unnecessary disk cleanup / runs cleanup in parallel, and records `runnerInputsDigest` in `record.json`. `docker.yml` attempts merge-queue promotion regardless of whether `runner_image` resolved `published` or `inline`, passing `RUNNER_INPUTS_DIGEST` to `merge-group-image.mjs verify` so promotion only succeeds when the merge-group image used the exact same Runner inputs digest. Promotion wait is capped at 3 minutes so `docker.yml` falls back quickly to building from source if a merge-group build is still running. **Reason and benefit** Makes merge-queue pre-built image promotion work with published Runner images so queued commits can promote verified bytes to GHCR instead of rebuilding after merge. **Breaking changes** None. ## What Changed - Added a read-only `runner_image` resolution and attestation verification job to `.github/workflows/docker-merge-group.yml` (non-blocking lookup, `persist-credentials: false`, SHA-pinned actions, no secrets or registry writes). - Routed canonical `amd64` merge-group builds in `docker-merge-group.yml` to `vars.CORE_PUBLICATION_RUNNER || 'cloud-release-32'`, skipped lockfile refresh when using a published Runner, parallelized `Free runner disk` with a `>= 50 GiB` skip, and passed `build-contexts`, `build-args`, and `labels` into `Build image archive`. - Updated `scripts/merge-group-image.mjs` to record and verify `runnerInputsDigest`, include `scripts/runner-image-resolve.mjs` in `pipelineFiles`, and cap `findWaitMs` at 3 minutes. - Updated `.github/workflows/docker.yml` to output `inputs_digest` from `runner_image`, run `Find the merge-queue build of this commit` even when `mode == 'published'`, and verify `--runner-inputs-digest` before promoting. - Updated `scripts/merge-group-image.test.mjs`, `server/src/__tests__/docker-build-stamp.test.ts`, and `server/src/__tests__/docker-runner-workflows.test.ts`. ## Verification - `node --test scripts/merge-group-image.test.mjs scripts/__tests__/docker-cache-export-policy.test.mjs scripts/__tests__/release-verify-workflow.test.mjs scripts/macos-runner-runtime-workflow.test.mjs` (all passed) - Vitest: `server/src/__tests__/docker-build-stamp.test.ts` (18/18 passed), `server/src/__tests__/docker-runner-workflows.test.ts` (11/11 passed) ## Risks - Low risk. Promotion remains strictly fail-closed: `docker.yml` runs `$BEFORE:scripts/merge-group-image.mjs`, refuses promotion on any pipeline file change, verifies commit SHA, tree SHA, architecture, archive blob digests, and exact `runnerInputsDigest`, and falls back to building from source on any mismatch or timeout. ## Model Used - Gemini 3 Pro (Antigravity agent with tool use, shell execution, and local test verification) ## 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
64bef50be0
commit
320d7fe76d
6 files changed
+300
-47
No files matched your search
@@ -51,6 +51,7 @@ jobs:
|
||||
attestations: read
|
||||
outputs:
|
||||
mode: ${{ steps.verify.outputs.mode || 'inline' }}
|
||||
inputs_digest: ${{ steps.verify.outputs.inputs_digest }}
|
||||
build_contexts: ${{ steps.verify.outputs.build_contexts }}
|
||||
labels: ${{ steps.verify.outputs.labels }}
|
||||
build_args: ${{ steps.verify.outputs.build_args }}
|
||||
@@ -104,6 +105,7 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
IMAGE: ${{ steps.resolve.outputs.image }}
|
||||
INPUTS_DIGEST: ${{ steps.resolve.outputs.inputs_digest }}
|
||||
LABELS: ${{ steps.resolve.outputs.labels }}
|
||||
BUILD_ARGS: ${{ steps.resolve.outputs.build_args }}
|
||||
run: |
|
||||
@@ -118,6 +120,7 @@ jobs:
|
||||
fi
|
||||
{
|
||||
echo "mode=published"
|
||||
echo "inputs_digest=$INPUTS_DIGEST"
|
||||
echo "build_contexts=runner-artifacts=docker-image://$IMAGE"
|
||||
echo "build_args=$BUILD_ARGS"
|
||||
echo "labels<<runner-image-labels-end"
|
||||
@@ -354,15 +357,15 @@ jobs:
|
||||
|
||||
# Build-before-merge. When the merge queue already built and probed this
|
||||
# exact commit (docker-merge-group.yml, with no registry credentials),
|
||||
# push those bytes, unless a published Runner image is used. The script
|
||||
# requires a successful merge-group run of this repository for this SHA
|
||||
# and checks the record's commit, tree, architecture and archive digest.
|
||||
# Any missing or mismatched proof, or any failure here, leaves
|
||||
# push those bytes. The script requires a successful merge-group run of
|
||||
# this repository for this SHA and checks the record's commit, tree,
|
||||
# architecture, Runner inputs digest, and archive digest. Any missing or
|
||||
# mismatched proof, or any failure here, leaves
|
||||
# `steps.promote.outputs.digest` empty and the build below runs as
|
||||
# before. The probe below and the exact-source gate apply either way.
|
||||
- name: Find the merge-queue build of this commit
|
||||
id: find
|
||||
if: needs.runner_image.outputs.mode != 'published' && github.repository == 'paperclipai/paperclip' && github.repository_id == '1170821064' && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
if: github.repository == 'paperclipai/paperclip' && github.repository_id == '1170821064' && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
continue-on-error: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -395,6 +398,7 @@ jobs:
|
||||
DIRECTORY: ${{ runner.temp }}/merge-group-image
|
||||
IMAGE_NAME: ghcr.io/${{ github.repository }}
|
||||
BEFORE: ${{ github.event.before }}
|
||||
RUNNER_INPUTS_DIGEST: ${{ needs.runner_image.outputs.inputs_digest }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Say plainly when this runner image cannot promote, instead of
|
||||
@@ -412,7 +416,7 @@ jobs:
|
||||
git show "$BEFORE:scripts/merge-group-image.mjs" > "$trusted"
|
||||
# Verify without writing a step output: the digest is set only after
|
||||
# the exact bytes are in the registry.
|
||||
verified="$(GITHUB_OUTPUT='' node "$trusted" verify --arch "$ARCH" --dir "$DIRECTORY" --since "$BEFORE")"
|
||||
verified="$(GITHUB_OUTPUT='' node "$trusted" verify --arch "$ARCH" --dir "$DIRECTORY" --since "$BEFORE" --runner-inputs-digest "$RUNNER_INPUTS_DIGEST")"
|
||||
digest="$(printf '%s\n' "$verified" | sed -n 's/^digest=//p')"
|
||||
printf '%s' "$digest" | grep -Eq '^sha256:[a-f0-9]{64}$'
|
||||
# --preserve-digests fails rather than re-encode, so the registry
|
||||
|
||||
Reference in new issue
Block a user