diff --git a/packages/paperclip-runner/scripts/build-provider-pack.mjs b/packages/paperclip-runner/scripts/build-provider-pack.mjs index 54e10b7f173..7d9ed8ae768 100644 --- a/packages/paperclip-runner/scripts/build-provider-pack.mjs +++ b/packages/paperclip-runner/scripts/build-provider-pack.mjs @@ -314,6 +314,13 @@ try { : spawnSync("git", ["diff", "--quiet", "--", "packages/paperclip-runner"], { cwd: workspaceRoot, }).status !== 0; + // Set only by the Runner image build (the `runner-artifacts` Dockerfile + // target): the identity of the inputs the image was built from, which is its + // `inputs-` tag. No check reads it. + const runnerInputsDigest = process.env.PAPERCLIP_RUNNER_INPUTS_DIGEST?.trim(); + if (runnerInputsDigest && !/^[0-9a-f]{64}$/.test(runnerInputsDigest)) { + throw new Error("PAPERCLIP_RUNNER_INPUTS_DIGEST must be 64 hexadecimal characters"); + } const payload = { compatibility, // Semantic digest of the Runner/pack contracts. Image packs are reused only @@ -330,6 +337,7 @@ try { }, target: { platform: process.platform, architecture: process.arch }, runnerSourceRevision: `${revision}${dirty ? "-dirty" : ""}`, + ...(runnerInputsDigest ? { runnerInputsDigest } : {}), distDigest, bridgeDigest: `sha256:${createHash("sha256") .update(opencodeProxySha) diff --git a/server/src/services/native-runtime/remote-provider-pack-verification.test.ts b/server/src/services/native-runtime/remote-provider-pack-verification.test.ts index 6321ebd22c7..3c4255a4dc5 100644 --- a/server/src/services/native-runtime/remote-provider-pack-verification.test.ts +++ b/server/src/services/native-runtime/remote-provider-pack-verification.test.ts @@ -114,6 +114,16 @@ describe("installed provider pack compatibility", () => { pack.payload.acpxProfileDigests = { codex: sha("different-codex") }; await expect(check(reseal(pack))).resolves.toEqual(reseal(pack)); }); + it("treats the Runner image inputs digest as provenance", async () => { + // A pack built in the Runner image records which image it came from. The + // controller's own pack may record another image, or none. + const pack = manifest("a"); + pack.payload.runnerInputsDigest = "c".repeat(64); + await expect(check(reseal(pack))).resolves.toEqual(reseal(pack)); + // The field is part of the sealed payload, so it cannot change unnoticed. + await expect(check({ ...reseal(pack), payload: { ...pack.payload, runnerInputsDigest: "d".repeat(64) } })) + .rejects.toThrow("runner_remote_provider_artifact_incompatible"); + }); it("checks only the selected ACPX profile", async () => { const current = manifest("b"), installed = manifest("a"); current.payload.acpxProfileDigests = { claude: sha("claude"), codex: sha("codex") }; diff --git a/server/src/services/native-runtime/remote-provider-pack-verification.ts b/server/src/services/native-runtime/remote-provider-pack-verification.ts index 9759ca9a52e..5d48ea89146 100644 --- a/server/src/services/native-runtime/remote-provider-pack-verification.ts +++ b/server/src/services/native-runtime/remote-provider-pack-verification.ts @@ -22,6 +22,8 @@ export type ProviderPackIdentity = { pins: { opencode: string; [key: string]: string | null }; target: { platform: string; architecture: string }; runnerSourceRevision: string; + /** Identity of the Runner image the pack was built in, when it was built there. Provenance only. */ + runnerInputsDigest?: string; artifacts: { nodeCommand: { path: string; sha256: string }; opencodeCommand: { path: string; sha256: string }; [key: string]: { path: string; sha256: string } }; }; };