Skip to content

Commit d4dc23c

Browse files
fix(ci): publish runtime images from verified native platforms (#85)
Publication ran timing- and signal-sensitive SDK tests under QEMU even though matching native PR images passed. Reuse native builds for publication, bind digest exports to tested image configs and provenance, and gate serialized complete-index tagging on both platform proofs. Keep SDK sources, tests, process deadlines, scanner policy, and production budgets unchanged.
1 parent e1659ed commit d4dc23c

7 files changed

Lines changed: 931 additions & 87 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
- name: Lint workflows
4444
uses: rhysd/actionlint@914e7df21a07ef503a81201c76d2b11c789d3fca # v1.7.12
4545

46+
- name: Test runtime publication contracts with offline command stubs
47+
run: python3 -m unittest discover -s scripts/runtime-image -p 'test_*.py' -v
48+
4649
test:
4750
name: ${{ matrix.check_name }}
4851
runs-on: ${{ matrix.os }}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Native Runtime Platform
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
publish:
7+
required: true
8+
type: boolean
9+
10+
jobs:
11+
native:
12+
name: Verify runtime image (${{ matrix.arch }})
13+
runs-on: ${{ matrix.os }}
14+
timeout-minutes: 45
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
arch: amd64
21+
- os: ubuntu-24.04-arm
22+
arch: arm64
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
with:
27+
persist-credentials: false
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
31+
32+
- name: Resolve image metadata
33+
id: meta
34+
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
35+
with:
36+
images: ghcr.io/${{ github.repository_owner }}/clawscan-runtime
37+
38+
- name: Require native hardware and exact source
39+
env:
40+
EXPECTED_ARCH: ${{ matrix.arch }}
41+
run: python3 scripts/runtime-image/publish.py native
42+
43+
- name: Build and load image with all SDK tests
44+
id: image
45+
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
46+
with:
47+
context: ./docker/clawscan-runtime
48+
file: docker/clawscan-runtime/Dockerfile
49+
platforms: linux/${{ matrix.arch }}
50+
push: false
51+
load: true
52+
provenance: false
53+
labels: ${{ steps.meta.outputs.labels }}
54+
tags: clawscan-runtime:ci
55+
56+
- name: Verify loaded config and smoke installed CLIs without credentials
57+
env:
58+
BUILD_DIGEST: ${{ steps.image.outputs.digest }}
59+
EXPECTED_ARCH: ${{ matrix.arch }}
60+
run: python3 scripts/runtime-image/publish.py verify
61+
62+
- name: Log in to GitHub Container Registry
63+
if: inputs.publish && github.event_name != 'pull_request'
64+
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.actor }}
68+
password: ${{ github.token }}
69+
70+
- name: Export verified native result by digest with provenance
71+
if: inputs.publish && github.event_name != 'pull_request'
72+
id: publish
73+
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
74+
with:
75+
context: ./docker/clawscan-runtime
76+
file: docker/clawscan-runtime/Dockerfile
77+
platforms: linux/${{ matrix.arch }}
78+
labels: ${{ steps.meta.outputs.labels }}
79+
provenance: mode=max
80+
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/clawscan-runtime,push-by-digest=true,name-canonical=true,push=true
81+
82+
- name: Bind registry digest to the smoke-tested config
83+
if: inputs.publish && github.event_name != 'pull_request'
84+
env:
85+
PUBLISHED_DIGEST: ${{ steps.publish.outputs.digest }}
86+
EXPECTED_ARCH: ${{ matrix.arch }}
87+
run: python3 scripts/runtime-image/publish.py published
88+
89+
- name: Retain successful export and smoke evidence
90+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
91+
with:
92+
name: runtime-image-proof-linux-${{ matrix.arch }}
93+
path: runtime-image-proof/
94+
if-no-files-found: error
95+
retention-days: 7

‎.github/workflows/runtime-image.yml‎

Lines changed: 49 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,63 @@ on:
77
tags:
88
- 'v*'
99
paths:
10-
- '.github/workflows/runtime-image.yml'
10+
- '.github/workflows/runtime-image*.yml'
11+
- 'scripts/runtime-image/**'
1112
- 'docker/clawscan-runtime/**'
1213
pull_request:
1314
paths:
14-
- '.github/workflows/runtime-image.yml'
15+
- '.github/workflows/runtime-image*.yml'
16+
- 'scripts/runtime-image/**'
1517
- 'docker/clawscan-runtime/**'
1618
workflow_dispatch:
1719

1820
permissions:
1921
contents: read
20-
packages: write
2122

2223
jobs:
24+
verify:
25+
if: github.event_name == 'pull_request'
26+
uses: ./.github/workflows/runtime-image-platform.yml
27+
permissions:
28+
contents: read
29+
with:
30+
publish: false
31+
2332
build:
2433
if: github.event_name != 'pull_request'
25-
name: Build runtime image
34+
uses: ./.github/workflows/runtime-image-platform.yml
35+
permissions:
36+
contents: read
37+
packages: write
38+
with:
39+
publish: true
40+
41+
merge:
42+
name: Publish complete runtime manifest
43+
needs: build
44+
if: github.event_name != 'pull_request' && needs.build.result == 'success'
2645
runs-on: ubuntu-latest
46+
timeout-minutes: 10
47+
permissions:
48+
contents: read
49+
packages: write
50+
concurrency:
51+
group: clawscan-runtime-publication
52+
cancel-in-progress: false
2753
steps:
2854
- name: Checkout
2955
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30-
31-
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
56+
with:
57+
persist-credentials: false
3358

3459
- name: Set up Docker Buildx
3560
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
3661

37-
- name: Log in to GitHub Container Registry
38-
if: github.event_name != 'pull_request'
39-
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
62+
- name: Download this run's native proofs
63+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
4064
with:
41-
registry: ghcr.io
42-
username: ${{ github.actor }}
43-
password: ${{ github.token }}
65+
pattern: runtime-image-proof-linux-*
66+
path: runtime-image-proof
4467

4568
- name: Resolve image metadata
4669
id: meta
@@ -53,85 +76,24 @@ jobs:
5376
type=semver,pattern={{major}}.{{minor}}
5477
type=raw,value=latest,enable={{is_default_branch}}
5578

56-
- name: Build image
57-
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
58-
with:
59-
context: ./docker/clawscan-runtime
60-
file: docker/clawscan-runtime/Dockerfile
61-
platforms: linux/amd64,linux/arm64
62-
push: ${{ github.event_name != 'pull_request' }}
63-
tags: ${{ steps.meta.outputs.tags }}
64-
labels: ${{ steps.meta.outputs.labels }}
65-
66-
verify:
67-
if: github.event_name == 'pull_request'
68-
name: Verify runtime image (${{ matrix.arch }})
69-
runs-on: ${{ matrix.os }}
70-
timeout-minutes: 45
71-
permissions:
72-
contents: read
73-
strategy:
74-
fail-fast: false
75-
matrix:
76-
include:
77-
- os: ubuntu-latest
78-
arch: amd64
79-
- os: ubuntu-24.04-arm
80-
arch: arm64
81-
steps:
82-
- name: Checkout
83-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
84-
85-
- name: Set up Docker Buildx
86-
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
87-
88-
# A real single-platform Docker export/load, not a cache-only PR build.
89-
# Native runners avoid treating emulated CLI execution as architecture proof.
90-
- name: Build and load image
91-
id: image
92-
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
79+
- name: Log in to GitHub Container Registry
80+
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
9381
with:
94-
context: ./docker/clawscan-runtime
95-
file: docker/clawscan-runtime/Dockerfile
96-
platforms: linux/${{ matrix.arch }}
97-
push: false
98-
load: true
99-
provenance: false
100-
tags: clawscan-runtime:ci
82+
registry: ghcr.io
83+
username: ${{ github.actor }}
84+
password: ${{ github.token }}
10185

102-
- name: Record immutable loaded-image identity
103-
shell: bash
86+
- name: Validate both digests and publish one complete index
10487
env:
105-
BUILD_DIGEST: ${{ steps.image.outputs.digest }}
106-
EXPECTED_ARCH: ${{ matrix.arch }}
107-
run: |
108-
set -euo pipefail
109-
[[ "$BUILD_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]
110-
image_id="$(docker image inspect --format '{{.Id}}' clawscan-runtime:ci)"
111-
[[ "$image_id" =~ ^sha256:[0-9a-f]{64}$ ]]
112-
[[ "$(docker image inspect --format '{{.Architecture}}' "$image_id")" == "$EXPECTED_ARCH" ]]
113-
[[ "$(docker image inspect --format '{{.Os}}' "$image_id")" == linux ]]
114-
mkdir -p runtime-image-proof
115-
printf 'source=%s\nplatform=linux/%s\nbuild_digest=%s\nloaded_image_id=%s\n' \
116-
"$(git rev-parse HEAD)" "$EXPECTED_ARCH" "$BUILD_DIGEST" "$image_id" \
117-
> runtime-image-proof/identity.txt
118-
printf 'RUNTIME_IMAGE_ID=%s\n' "$image_id" >> "$GITHUB_ENV"
119-
cat runtime-image-proof/identity.txt >> "$GITHUB_STEP_SUMMARY"
120-
121-
- name: Smoke installed CLIs without provider credentials
122-
shell: bash
123-
run: |
124-
set -euo pipefail
125-
docker run --rm --network none "$RUNTIME_IMAGE_ID" /bin/sh -ec '
126-
skillspector --help
127-
aig-skill-scan --help
128-
codex --version
129-
' 2>&1 | tee runtime-image-proof/cli-smoke.txt
88+
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
89+
BUILD_RESULT: ${{ needs.build.result }}
90+
GH_TOKEN: ${{ github.token }}
91+
run: python3 scripts/runtime-image/publish.py merge
13092

131-
- name: Retain successful export and smoke evidence
93+
- name: Retain manifest identity
13294
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
13395
with:
134-
name: runtime-image-proof-linux-${{ matrix.arch }}
135-
path: runtime-image-proof/
96+
name: runtime-image-manifest
97+
path: runtime-image-proof/manifest.json
13698
if-no-files-found: error
13799
retention-days: 7

‎docs/scanner-runtime.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,36 @@ Upstream pin changes must keep these gates green; remove a patch when upstream
107107
provides the equivalent tested behavior. The runtime updater follows A.I.G's Git
108108
HEAD rather than PyPI until a compatible release is available.
109109

110+
## Native image publication
111+
112+
Runtime Image uses the same native Linux amd64 and arm64 build/load/smoke jobs
113+
for pull requests and publication. Both execute every existing Dockerfile SDK
114+
test with unchanged deadlines. QEMU is not an equivalent environment for these
115+
process-, signal-, and wall-clock-sensitive tests. A native pass does not prove
116+
arbitrary emulation correctness.
117+
118+
Pull requests have read-only repository permissions, no package-write permission,
119+
no registry login, and no publication. Main, version tags, and manual runs export
120+
each smoke-tested platform by immutable registry digest with BuildKit provenance.
121+
The local Docker export cannot retain provenance; the subsequent registry export
122+
uses the same runner's verified build result and must have the identical image
123+
config digest, architecture, and source revision before it is accepted.
124+
125+
Only a successful two-platform fan-in can update metadata-generated tags. The
126+
serialized merge checks this run's source/tree/context identity, both image
127+
configs, both provenance attachments, and the complete candidate index before
128+
tagging. Each registry tag points to one complete two-platform index, never a
129+
partially updated platform list. Multiple tag updates are not a registry-wide
130+
transaction; a failed write can leave some aliases unchanged, but never authorizes
131+
an incomplete index. Superseded branch runs fail the final source-ref check.
132+
133+
Download the run's `runtime-image-manifest` artifact for `manifest.json`: it records
134+
the final immutable digest, revision, native platform proofs, config digests, and
135+
preserved attestation descriptors. Verify both the artifact and the live registry
136+
before adopting the image; a green pull request alone is not publication proof.
137+
Offline workflow and command-stub controls run with `go test ./scripts/runtime-image`
138+
and `python3 -m unittest discover -s scripts/runtime-image -p 'test_*.py' -v`.
139+
110140
## Consume without a public release
111141

112142
Check out the exact reviewed ClawScan commit, then build both binary and image:

0 commit comments

Comments
 (0)