From f55759942b8c17b258168848ca769ae99d9243ec Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Wed, 23 Sep 2026 11:27:43 -0700 Subject: [PATCH] fix(runner): accept compatible Codex releases from 0.149.0 (#13853) Keep the minimum fixed at 0.149.0 until a deliberate maintainer change. Accept stable versions below 0.157.0 separately from the reproducible install pin. Co-Authored-By: Paperclip --- .../paperclip-runner-compatibility.md | 44 +++++++++++++++++++ .../codex-runtime-compatibility.test.ts | 39 ++++++++++++++++ .../codex-runtime-compatibility.ts | 43 ++++++++++++++++++ .../native-session-executor.test.ts | 24 ++++++++-- .../native-runtime/native-session-executor.ts | 19 ++++++-- 5 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 server/src/services/native-runtime/codex-runtime-compatibility.test.ts create mode 100644 server/src/services/native-runtime/codex-runtime-compatibility.ts diff --git a/doc/architecture/paperclip-runner-compatibility.md b/doc/architecture/paperclip-runner-compatibility.md index b648186c5fd..effabc1eba4 100644 --- a/doc/architecture/paperclip-runner-compatibility.md +++ b/doc/architecture/paperclip-runner-compatibility.md @@ -44,6 +44,50 @@ The server must not fall back from a selected `paperclip_runner` start to `codex_local`. A configuration or rollout error must be visible. Silent fallback would hide the runtime that executed the task. +## Remote Codex version window + +Remote native Codex runs accept stable CLI versions **`>=0.149.0 <0.157.0`**. +The install pin remains `0.156.0`. A sandbox image can therefore use an older +compatible Codex without failing startup or installing another copy. + +The minimum is fixed at **`0.149.0`** until maintainers deliberately change it. +It is not a rolling one-month support window. The official +[`@openai/codex` publication history](https://registry.npmjs.org/@openai/codex) +records `0.149.0` on 2026-08-20, `0.153.4` on 2026-09-04, and `0.156.0` on +2026-09-22. See also the [Codex changelog](https://learn.chatgpt.com/docs/changelog). +This is an explicit compatibility window, not a claim that every Codex minor +release follows a backward-compatible protocol. + +- Stable patch releases within the window are accepted. Alpha, dev, custom + builds, malformed output, older releases, and the next minor release are rejected. +- A compatible difference from the install pin produces one diagnostic per + version during backend preparation, rather than stopping the task. +- The same check applies to discovered, explicitly staged, and npm-installed + remote Codex executables, including the final executable after linking. +- For an incompatible image, the existing + `PAPERCLIP_RUNNER_REMOTE_CODEX_NPM_SPEC=@openai/codex@0.156.0` configuration + allows installation of the pinned runtime. Without that configuration, + startup reports the supported range and the remediation. +- Runner binary contracts, required runner capabilities, artifact digests, + provider-pack manifests, and runtime permission checks are unchanged. + This window does not relax the separate ACP provider-pack qualification. + +When qualifying newer Codex releases, review the upper bound in +`server/src/services/native-runtime/codex-runtime-compatibility.ts`. Updating +the install pin or upper bound does not raise the minimum. Raising `0.149.0` +requires a separate, explicit maintainer decision and compatibility evidence. +Do not derive eligibility from the current date or fetch release metadata +during startup: an idle installation must not become incompatible merely +because time passed. + +Qualification on 2026-09-22 used the actual macOS ARM64 `0.149.0` and `0.156.0` +app-server binaries with a local deterministic Responses API fixture. Both +passed initialization, thread creation with a dynamic tool, a tool-call/result +round trip, turn completion, and thread resume. This verifies the tested +protocol path; it is not a live model, Linux sandbox, or exhaustive feature test. +Version-boundary and remote artifact-preparation regressions are covered by +`codex-runtime-compatibility.test.ts` and `native-session-executor.test.ts`. + ## Direct adapter boundary This rule applies to every built-in and plugin direct adapter. It includes: diff --git a/server/src/services/native-runtime/codex-runtime-compatibility.test.ts b/server/src/services/native-runtime/codex-runtime-compatibility.test.ts new file mode 100644 index 00000000000..3f9a72542ef --- /dev/null +++ b/server/src/services/native-runtime/codex-runtime-compatibility.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, it, vi } from "vitest"; +import { + isSupportedRemoteCodexVersion, + parseCodexCliVersion, +} from "./codex-runtime-compatibility.js"; + +describe("remote Codex compatibility window", () => { + it("keeps the fixed minimum supported as time passes", () => { + vi.useFakeTimers(); + try { + vi.setSystemTime(new Date("2030-01-01T00:00:00Z")); + expect(isSupportedRemoteCodexVersion("0.149.0")).toBe(true); + expect(isSupportedRemoteCodexVersion("0.148.99")).toBe(false); + } finally { + vi.useRealTimers(); + } + }); + it.each(["0.149.0", "0.149.1", "0.150.0", "0.150.1", "0.151.0", "0.152.1", "0.153.4", "0.154.0", "0.155.1", "0.156.0", "0.156.99"])( + "accepts stable supported version %s", (version) => { + expect(isSupportedRemoteCodexVersion(version)).toBe(true); + expect(parseCodexCliVersion(`codex-cli ${version}\n`)).toBe(version); + }, + ); + it.each(["0.148.99", "0.100.0", "0.157.0", "0.999.0", "1.0.0", "0.156.0-alpha.1", "0.149.0-dev", "0.156.0+custom", "00.149.0", "0.149", "0.149.9007199254740992", ""])( + "rejects unsupported or ambiguous version %s", (version) => { + expect(isSupportedRemoteCodexVersion(version)).toBe(false); + }, + ); + it("allows separate diagnostic lines and stderr version output", () => { + expect(parseCodexCliVersion("WARNING: PATH unchanged\r\n\rcodex-cli 0.149.0\r\n")).toBe("0.149.0"); + }); + it.each([ + "codex-cli 0.156.0-alpha.1", "codex-cli 0.156.0+custom", "codex-cli 0.156.0 garbage", + "wrapper says codex-cli 0.156.0", "codex 0.156.0", "0.156.0", "", + "codex-cli 0.149.0\ncodex-cli 0.156.0", + ])("does not partially parse %j as a supported stable CLI", (output) => { + expect(parseCodexCliVersion(output)).toBeNull(); + }); +}); diff --git a/server/src/services/native-runtime/codex-runtime-compatibility.ts b/server/src/services/native-runtime/codex-runtime-compatibility.ts new file mode 100644 index 00000000000..d5a1a25ba71 --- /dev/null +++ b/server/src/services/native-runtime/codex-runtime-compatibility.ts @@ -0,0 +1,43 @@ +/** + * The app-server compatibility window is separate from the reproducible install + * pin. The minimum stays at 0.149.0 until maintainers explicitly change it; + * newer install pins and the passage of time must not raise it automatically. + * Qualify the upper bound separately when adding support for a new Codex minor. + * Do not query a registry at startup. + */ +export const REMOTE_CODEX_MINIMUM_VERSION = "0.149.0"; +export const REMOTE_CODEX_MAXIMUM_VERSION_EXCLUSIVE = "0.157.0"; +export const REMOTE_CODEX_SUPPORTED_RANGE = + `>=${REMOTE_CODEX_MINIMUM_VERSION} <${REMOTE_CODEX_MAXIMUM_VERSION_EXCLUSIVE}`; + +const STABLE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/; + +function stableVersionParts(version: string): number[] | null { + const match = STABLE_VERSION.exec(version); + if (!match) return null; + const parts = match.slice(1).map(Number); + return parts.every(Number.isSafeInteger) ? parts : null; +} + +/** Parse a complete version line so alpha/dev suffixes cannot pass as stable. */ +export function parseCodexCliVersion(output: string): string | null { + const versions = output.split(/\r?\n/) + .map((line) => /^codex-cli (\S+)$/.exec(line.trim())?.[1]) + .filter((version): version is string => version !== undefined); + if (versions.length !== 1 || !stableVersionParts(versions[0]!)) return null; + return versions[0]!; +} + +export function isSupportedRemoteCodexVersion(version: string): boolean { + const parts = stableVersionParts(version); + if (!parts) return false; + const minimum = stableVersionParts(REMOTE_CODEX_MINIMUM_VERSION)!; + const maximum = stableVersionParts(REMOTE_CODEX_MAXIMUM_VERSION_EXCLUSIVE)!; + const compare = (other: number[]) => { + for (let index = 0; index < parts.length; index++) { + if (parts[index] !== other[index]) return parts[index]! - other[index]!; + } + return 0; + }; + return compare(minimum) >= 0 && compare(maximum) < 0; +} diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index f2573d3bd4f..3be76308f40 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -10395,7 +10395,14 @@ describe("runnerd provider runtime wiring", () => { } }); - it.each(["current", "stale", "missing", "retained", "retained-mismatch", "retained-error", "retained-timeout", "retained-explicit"])("uses shared Codex and the server-owned replacement artifact (image=%s)", async (image) => { + it.each([ + ...["current", "stale", "missing", "retained", "retained-mismatch", "retained-error", "retained-timeout", "retained-explicit"] + .map((image) => ({ image, version: "0.156.0", compatible: true })), + ...["0.149.0", "0.149.1", "0.153.4", "0.156.1"] + .map((version) => ({ image: "current", version, compatible: true })), + ...["0.148.9", "0.157.0", "1.0.0", "0.156.0-alpha.1", "unknown"] + .map((version) => ({ image: "current", version, compatible: false })), + ])("uses shared Codex and the server-owned replacement artifact (image=$image, Codex=$version)", async ({ image, version, compatible }) => { const retained = image.startsWith("retained"); const exactRetained = image === "retained" || image === "retained-explicit"; const needsReplacement = image !== "current" && !exactRetained; @@ -10406,6 +10413,7 @@ describe("runnerd provider runtime wiring", () => { await writeFile(controllerArtifact, "fixture runner artifact"); state.resolveRunnerBinary.mockReturnValueOnce(controllerArtifact); } + const onLog = vi.fn(async () => undefined); const syncIn = vi.fn(async () => undefined); const remoteExecute = vi.fn( async (command: { command: string; args?: string[] }) => { @@ -10436,7 +10444,7 @@ describe("runnerd provider runtime wiring", () => { ) { throw new Error("reached-preinstalled-codex-verification"); } - stdout = "codex-cli 0.156.0"; + stdout = `codex-cli ${version}`; } else if (script === "uname -s; uname -m") { stdout = `${process.platform === "darwin" ? "Darwin" : "Linux"}\n${process.arch === "arm64" ? "arm64" : "x86_64"}\n`; } else if (script.includes("command -v paperclip-runnerd")) { @@ -10464,6 +10472,7 @@ describe("runnerd provider runtime wiring", () => { db: leaseDb(execution), execution, runnerInstanceId: "runner-image-runtime", + onLog, ...(image === "retained-explicit" ? { runnerRemoteBinaryPath: controllerArtifact } : {}), runnerIngressAuthorized: true, runnerExecutionTarget: { @@ -10485,8 +10494,17 @@ describe("runnerd provider runtime wiring", () => { controlPlaneRegistration: (authority: unknown) => Promise; }; await expect(transport.controlPlaneRegistration({})).rejects.toThrow( - "reached-preinstalled-codex-verification", + compatible ? "reached-preinstalled-codex-verification" : "runner_remote_provider_artifact_incompatible: supported Codex versions >=0.149.0 <0.157.0", ); + if (!compatible) { + expect(syncIn).not.toHaveBeenCalled(); + expect(remoteExecute.mock.calls.some(([call]) => call.command === "npm" || call.args?.[1]?.includes("paperclip_codex_launcher_tmp"))).toBe(false); + expect(onLog).not.toHaveBeenCalledWith("stderr", expect.stringContaining("using compatible Codex")); + return; + } + if (version !== "0.156.0") { + expect(onLog).toHaveBeenCalledWith("stderr", expect.stringContaining(`using compatible Codex ${version}`)); + } if (needsReplacement) { expect(transport.runnerBinary).toBe(controllerArtifact); expect(syncIn).toHaveBeenCalledTimes(1); diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index e0441edce43..48de155f837 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -1,3 +1,8 @@ +import { + isSupportedRemoteCodexVersion, + parseCodexCliVersion, + REMOTE_CODEX_SUPPORTED_RANGE, +} from "./codex-runtime-compatibility.js"; import { createNativeToolTrace, type NativeToolTrace } from "./native-tool-trace.js"; import { createNativeGitHubAccess, type NativeGitHubAccess } from "./native-github-access.js"; import { resolveGitHubOperationCredentials } from "../github-operation-credentials.js"; @@ -10666,6 +10671,7 @@ async function createRunnerdBackendWithinSessionClaim( assertRemoteRunnerBuildMetadata(metadata, requiredMode); }; + const reportedCodexVersions = new Set(); const verifyRemoteCodex = async (executable = remoteCodexBinary) => { if (!remoteTarget || !remoteCommandRunner || !executable) return; const versionResult = await remoteCommandRunner.execute({ @@ -10679,10 +10685,17 @@ async function createRunnerdBackendWithinSessionClaim( throw new Error("runner_remote_codex_artifact_verification_failed"); } const versionOutput = `${versionResult.stdout}\n${versionResult.stderr}`; - const version = versionOutput.match(/\bcodex-cli\s+(\d+\.\d+\.\d+)\b/)?.[1]; - if (version !== REMOTE_PROVIDER_PACK_PINS.codex) { + const version = parseCodexCliVersion(versionOutput); + if (!version || !isSupportedRemoteCodexVersion(version)) { throw new Error( - `runner_remote_provider_artifact_incompatible: expected Codex ${REMOTE_PROVIDER_PACK_PINS.codex}, received ${version ?? "an unrecognized version"}`, + `runner_remote_provider_artifact_incompatible: supported Codex versions ${REMOTE_CODEX_SUPPORTED_RANGE}, received ${version ?? "an unrecognized or prerelease version"}; install a supported stable Codex release or configure PAPERCLIP_RUNNER_REMOTE_CODEX_NPM_SPEC=@openai/codex@${REMOTE_PROVIDER_PACK_PINS.codex}`, + ); + } + if (version !== REMOTE_PROVIDER_PACK_PINS.codex && !reportedCodexVersions.has(version)) { + reportedCodexVersions.add(version); + await input.onLog?.( + "stderr", + `[paperclip-runner] using compatible Codex ${version} (supported ${REMOTE_CODEX_SUPPORTED_RANGE}; install pin ${REMOTE_PROVIDER_PACK_PINS.codex})\n`, ); } };