fix(runner): support native OpenCode on macOS SSH hosts (#22534)

## Thinking Path
> - Paperclip coordinates agents across local, SSH, and sandbox
environments.
> - Native Runner must launch artifacts for the execution host.
> - A Linux controller currently selects Linux OpenCode assets for a
macOS SSH host.
> - Remote launch-file validation also accepts only ELF executables.
> - The standard Core image must carry a verified Mac runtime for this
host pair.
> - This pull request adds that runtime and selects it for Apple Silicon
SSH hosts.
> - Self-hosted and hosted controllers can use the same generic
implementation.

## Linked Issues or Issue Description
**What happened?**
A native OpenCode run on an Apple Silicon SSH host receives Linux
controller artifacts. Its private launch-file verifier also rejects
Mach-O files. A working legacy CLI agent does not exercise this path.

**Expected behavior**
The controller must select and verify the target's native daemon, Node,
OpenCode executable, and proxy. Existing Linux targets and legacy agents
must keep their current behavior.

**Steps to reproduce**
1. Run a standard Linux Core image.
2. Select an SSH environment on an Apple Silicon Mac.
3. Start a native OpenCode agent with a compatible model connection.
4. Observe the incompatible runtime selection before useful agent work.

**Paperclip version or commit**
Base: `324ec1f537a9ba1e84239faa81bcef326a5dd1b7`.

**Deployment mode**
Docker or another Linux controller, with macOS ARM64 execution over SSH.

Related work: #21662 covers local OpenCode confinement. #22236 covers
SSH process cleanup. This change does not depend on either PR. No
duplicate macOS OpenCode runtime PR was found.

## What Changed
- Select a verified `darwin-arm64` runtime for OpenCode SSH targets.
Preserve the Linux image default and explicit operator overrides.
- Verify Mach-O launch files against the admitted architecture, file
digests, and remote account. Keep existing Linux receipt and recovery
behavior.
- Build the Mac runtime on an Apple Silicon CI host with standalone Node
24.21.0. Keep OpenCode pinned to 1.18.34.
- Package the sealed OpenCode runtime artifacts and required package
metadata. Omit other harness distributions and their optional
qualification inventories.
- Verify archive provenance and safe extraction on Linux. Include the
runtime in standard and merge-queue Core images. Avoid storing the
transport archive in an image layer.
- Reuse artifacts only from successful protected master image builds
with identical runtime inputs. Test cache trust boundaries and register
the script tests in CI.
- Document runtime delivery, manual image inputs, and the initial Apple
Silicon scope. No Cloud source, schema, or agent configuration changes.

## Verification
- `pnpm -r typecheck` — passed.
- `pnpm build` — passed.
- Focused OpenCode artifact selection and private staging tests — 21
passed.
- Focused native executor tests for OpenCode, SSH, and provider packs —
60 passed.
- Real Rust daemon transport tests with the OpenCode protocol fixture —
4 passed.
- Installed OpenCode 1.18.34 server qualification with a local provider
fixture — 3 passed.
- Runtime packaging, cache trust, workflow, image-contract, and
merge-queue tests — 26 passed.
- The CI release-workflow test group, including canary reuse and
provenance — 218 passed.
- Docker workflow and build-stamp guards — 29 passed after adding the
Mac digest expectation, updating the excluded-source COPY expectation,
and removing the redundant production commit ARG.
- The source SDK registry, public-type, and evidence checks — 59 passed
after updating only the root package metadata hash. Lock, compiler,
parser, and model pins did not change.
- Fresh-host provider-pack upload harness — 7 passed. The new regression
first failed with `package_version:acpx`, then passed after the required
metadata was preserved.
- Node version policy — passed against a clean tracked-file snapshot.
Generated local provider assets make the direct workspace scan fail;
they are absent from the CI checkout.
- Built, packaged, installed, and verified the actual Mac runtime. Both
the controller verifier and the remote startup verifier accept its pins,
target, sealed files, manifest, and package metadata. The pre-change
private launch verifier rejects the real Mach-O files; the candidate
accepts those same files. The dedicated archive is about 101 MB.
- Live native smoke: real Mac daemon, private staged Mach-O files,
OpenCode 1.18.34, and a local GLM-5.3 backend. The model read two files,
edited the implementation, ran three tests, completed the semantic
finish call, and summarized the three passes. An independent test run
passed. The test file stayed unchanged. This used the existing `allow`
mode and a scratch account-home fixture on a Mac. It does not prove
hosted SSH dispatch.
- The full CI workflow passed on
`ae74808631f1933edec89aa1e80db7f2b756aca3`: server test shards, Runner
Rust and native server tests, type checking, builds, browser suites,
image checks, the native Mac producer, and Linux runtime installation.
Greptile is 5/5 with no unresolved threads.
- Local `pnpm test:run` used a disposable PostgreSQL 18 fixture after
embedded Postgres failed to start because its macOS package lacks
dynamic libraries. All six chat shards passed (1,971 tests). The
redundant unsharded local run was interrupted during the general-server
group after all current-head CI test jobs passed. The later local
workspace and serialized groups did not run. The owned PostgreSQL
fixture is stopped. This is not a local full-suite pass.

Retained review failures: the first PR revision omitted package metadata
and did not ignore downloaded image inputs. The fresh-host upload
regression reproduced the metadata failure before its fix. Generated
inputs are now ignored. CI also exposed a missing Node policy exception
for the pinned Mac producer; the exception is limited to that producer
job. A later policy attempt exposed an old exact-dependency assertion in
canary reuse tests. The assertion now covers the added runtime and
evaluates the publication gate for success, failure, cancellation, and
skip outcomes. The Runner support suite then found that the new test
registration changed a pinned root package input; the standard source
registry generator updated that one hash, and all 59 affected tests
passed. The server matrix then found four outdated image guard
expectations and a duplicate production commit ARG. The focused image
guards now pass after updating those expectations and keeping one commit
ARG before Mac verification.

Retained failures: the first producer attempt used Homebrew Node, which
failed the relocation check. The successful producer used standalone
Node 24.21.0. Live smoke attempts also encountered a stopped tunnel, an
upstream model failure, and the existing Rust restriction on OpenCode
permission requests in `ask` mode. The successful tool trace used the
existing `allow` mode. Its initial reporter looked for tool names in
generic item events; verification of the retained canonical tool events
and an independent rerun confirmed the result. The upstream model
failure is not explained by a later pass.

Not run locally: a full Docker image build, because the existing Docker
daemon does not respond. The PR adds native producer qualification and
Linux installation verification to CI. Hosted deployment, remote
service-account dispatch, and hosted continuation remain acceptance
steps after deployment.

## Risks
- A cold Mac runtime build adds CI time when Runner or producer inputs
change. Reuse is bounded and accepts only a successful protected master
producer. The artifact digest and runtime input identity remain
verified.
- Standard images gain a dedicated Mac runtime payload. Manual image
builds can omit it; Mac OpenCode SSH runs then fail with a named
missing-runtime error. Linux behavior remains available.
- This release covers Apple Silicon SSH distribution. It does not
qualify Intel Mac distribution or expand other harness support.
- The OpenCode permission bridge keeps its existing behavior. This PR
does not add `ask` approval support.
- No saved run/session schema or provider pin changes. Existing Linux
receipts retain their interpretation. A surviving admitted Runner
bypasses new artifact discovery. Legacy agents are not converted.
Existing account-change and old-receipt restoration tests remain in
coverage.
- No migration, cluster change, new sandbox image requirement, or Cloud
control-plane change. A staging application rebuild and deployment are
separate from this PR.

## Model Used
OpenAI GPT-6, through Codex, with repository tools, code execution,
tests, and SSH inspection. The session does not expose a more specific
model ID or context-window size.

## 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip authored and GitHub committed 2026-11-22 00:07:34 -08:00
1 parent e5f0e1508b
commit 28ed2f1db0
27 files changed
+806 -18

No files matched your search

+14
View File
@@ -22,7 +22,14 @@ concurrency:
cancel-in-progress: true
jobs:
macos_runner_runtime:
uses: ./.github/workflows/macos-runner-runtime.yml
permissions:
contents: read
actions: read
build:
needs: macos_runner_runtime
if: github.repository == 'paperclipai/paperclip' && github.repository_id == '1170821064' && github.event.merge_group.base_ref == 'refs/heads/master'
strategy:
fail-fast: false
@@ -49,6 +56,12 @@ jobs:
fetch-depth: 0
filter: blob:none
- name: Download the native macOS SSH runtime
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: ${{ needs.macos_runner_runtime.outputs.artifact_name }}
path: docker/remote-runtimes/
# The merge queue fast-forwards master to this exact commit, so these
# stamps match what a master build of the same commit would carry.
- name: Compute build version
@@ -133,6 +146,7 @@ jobs:
build-args: |
PAPERCLIP_BUILD_VERSION=${{ steps.build-version.outputs.version }}
PAPERCLIP_BUILD_COMMIT=${{ github.sha }}
PAPERCLIP_MACOS_RUNTIME_INPUTS_DIGEST=${{ needs.macos_runner_runtime.outputs.inputs_digest }}
CLI_TOOLS_CACHE_EPOCH=${{ steps.tools-epoch.outputs.epoch }}
platforms: ${{ matrix.platform }}
push: false
+15 -2
View File
@@ -33,6 +33,12 @@ concurrency:
cancel-in-progress: false
jobs:
macos_runner_runtime:
uses: ./.github/workflows/macos-runner-runtime.yml
permissions:
contents: read
actions: read
runner_image:
name: Resolve the Runner image of this commit
if: vars.RUNNER_IMAGE_CONSUME_ENABLED == 'true' && github.repository == 'paperclipai/paperclip' && github.repository_id == '1170821064'
@@ -196,8 +202,8 @@ jobs:
# digest; `merge` assembles the manifest list. Both architectures remain
# available to self-hosted installations and downstream image composers.
build-and-push:
needs: [reuse_canary_image, runner_image]
if: ${{ !cancelled() && (needs.reuse_canary_image.result == 'skipped' || (needs.reuse_canary_image.result == 'success' && needs.reuse_canary_image.outputs.reused == 'false')) }}
needs: [reuse_canary_image, runner_image, macos_runner_runtime]
if: ${{ !cancelled() && needs.macos_runner_runtime.result == 'success' && (needs.reuse_canary_image.result == 'skipped' || (needs.reuse_canary_image.result == 'success' && needs.reuse_canary_image.outputs.reused == 'false')) }}
strategy:
# Independent legs: one architecture failing should still publish
# nothing, but it must not also hide the other's logs behind a
@@ -230,6 +236,12 @@ jobs:
# from every historical revision of this large repository.
filter: blob:none
- name: Download the native macOS SSH runtime
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: ${{ needs.macos_runner_runtime.outputs.artifact_name }}
path: docker/remote-runtimes/
# `.git` is dockerignored, so a running image cannot derive its own
# version and otherwise reports the source package.json placeholder in
# analytics and the debug panel. Compute it here from the pristine
@@ -456,6 +468,7 @@ jobs:
build-args: |
PAPERCLIP_BUILD_VERSION=${{ steps.build-version.outputs.version }}
PAPERCLIP_BUILD_COMMIT=${{ github.sha }}
PAPERCLIP_MACOS_RUNTIME_INPUTS_DIGEST=${{ needs.macos_runner_runtime.outputs.inputs_digest }}
CLI_TOOLS_CACHE_EPOCH=${{ steps.tools-epoch.outputs.epoch }}
${{ needs.runner_image.outputs.build_args }}
build-contexts: ${{ needs.runner_image.outputs.build_contexts }}
+139
View File
@@ -0,0 +1,139 @@
name: macOS OpenCode SSH runtime
on:
workflow_call:
outputs:
artifact_name:
value: ${{ jobs.build.outputs.artifact_name }}
inputs_digest:
value: ${{ jobs.build.outputs.inputs_digest }}
pull_request:
paths:
- .github/workflows/macos-runner-runtime.yml
- .github/workflows/docker.yml
- .github/workflows/docker-merge-group.yml
- Dockerfile
- packages/paperclip-runner/**
- scripts/macos-runner-runtime.mjs
- scripts/macos-runner-runtime-cache.mjs
- server/src/services/native-runtime/remote-opencode-artifacts*
- server/src/services/native-runtime/remote-opencode-runtime*
permissions:
contents: read
actions: read
jobs:
build:
runs-on: macos-15
timeout-minutes: 45
outputs:
artifact_name: ${{ steps.cached.outputs.artifact_name }}
inputs_digest: ${{ steps.cached.outputs.digest }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86
with:
version: 9.15.4
run_install: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
with:
node-version: 24.21.0
package-manager-cache: false
- name: Find an identical runtime from a successful master image build
id: cached
env:
GITHUB_TOKEN: ${{ github.token }}
run: node scripts/macos-runner-runtime-cache.mjs
- name: Reuse the verified runtime artifact
if: steps.cached.outputs.run_id != ''
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: ${{ steps.cached.outputs.artifact_name }}
run-id: ${{ steps.cached.outputs.run_id }}
github-token: ${{ github.token }}
path: ${{ runner.temp }}/macos-runner-runtime
- run: pnpm install --frozen-lockfile
if: steps.cached.outputs.run_id == ''
- run: pnpm --filter @paperclipai/paperclip-runner build:typescript
if: steps.cached.outputs.run_id == ''
- run: pnpm --filter @paperclipai/paperclip-runner build:binary
if: steps.cached.outputs.run_id == ''
- name: Build the pinned native provider pack
if: steps.cached.outputs.run_id == ''
env:
PAPERCLIP_RUNNER_SOURCE_REVISION: ${{ github.sha }}
run: node packages/paperclip-runner/scripts/build-provider-pack.mjs "$RUNNER_TEMP/macos-provider-pack"
- name: Qualify the actual OpenCode server
if: steps.cached.outputs.run_id == ''
env:
PAPERCLIP_OPENCODE_QUALIFY: "1"
run: |
export PAPERCLIP_TEST_OPENCODE_BINARY="$RUNNER_TEMP/macos-provider-pack/node_modules/opencode-ai/bin/opencode.exe"
node --test packages/paperclip-runner/scripts/qualify-opencode-runtime.test.mjs
- name: Package the macOS SSH runtime
if: steps.cached.outputs.run_id == ''
env:
RUNTIME_INPUTS_DIGEST: ${{ steps.cached.outputs.digest }}
run: |
node scripts/macos-runner-runtime.mjs package \
"$RUNNER_TEMP/macos-provider-pack" \
packages/paperclip-runner/dist/bin/paperclip-runnerd \
"$GITHUB_SHA" "$RUNNER_TEMP/macos-runner-runtime" "$RUNTIME_INPUTS_DIGEST"
- name: Verify the unpacked pack with the remote startup verifier
if: steps.cached.outputs.run_id == ''
env:
RUNTIME_INPUTS_DIGEST: ${{ steps.cached.outputs.digest }}
run: |
node scripts/macos-runner-runtime.mjs install \
"$RUNNER_TEMP/macos-runner-runtime" "$RUNNER_TEMP/qualified-runtimes" "$GITHUB_SHA" "$RUNTIME_INPUTS_DIGEST"
node --import ./server/node_modules/tsx/dist/loader.mjs --input-type=module <<'JS'
import { execFile } from 'node:child_process';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { promisify } from 'node:util';
import { verifyRemoteProviderPack } from './server/src/services/native-runtime/remote-provider-pack-verification.ts';
const packRoot = join(process.env.RUNNER_TEMP, 'qualified-runtimes/darwin-arm64/provider-pack');
const manifest = JSON.parse(readFileSync(join(packRoot, 'provider-pack.json'), 'utf8'));
const execute = async request => {
try {
const result = await promisify(execFile)(request.command, request.args, { cwd: request.cwd, timeout: request.timeoutMs });
return { ...result, exitCode: 0, signal: null, timedOut: false, pid: null, startedAt: null };
} catch (error) {
return { stdout: error.stdout ?? '', stderr: error.stderr ?? String(error), exitCode: error.code,
signal: error.signal ?? null, timedOut: Boolean(error.killed), pid: null, startedAt: null };
}
};
await verifyRemoteProviderPack({ runner: { execute }, cwd: packRoot, packRoot, manifest });
JS
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ steps.cached.outputs.artifact_name }}
path: ${{ runner.temp }}/macos-runner-runtime/
if-no-files-found: error
retention-days: 7
verify_linux_controller:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
with:
node-version: 24
package-manager-cache: false
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: ${{ needs.build.outputs.artifact_name }}
path: ${{ runner.temp }}/macos-runner-runtime
- name: Verify that Linux can install the Mac runtime without executing it
env:
RUNTIME_INPUTS_DIGEST: ${{ needs.build.outputs.inputs_digest }}
run: |
node scripts/macos-runner-runtime.mjs install \
"$RUNNER_TEMP/macos-runner-runtime" "$RUNNER_TEMP/installed-runtimes" "$GITHUB_SHA" "$RUNTIME_INPUTS_DIGEST"