diff --git a/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md b/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md index e1dd0f06fdb..79907dd0aa8 100644 --- a/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md +++ b/doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md @@ -201,8 +201,7 @@ this field, the provider must: - Move the source Runner state (`runner-state.json`) out of the Runner state directory into an archive, so that the Runner creates new state. - Start the Runner as the claimant identity with the fresh `bootstrapTicket`. -- Return `runner: { version, digest }` on the `resumed` result. A provider may - also return `archivedState`, the archived Runner state; Core does not read it. +- Return `runner: { version, digest }` on the `resumed` result. The provider is the authority on whether a park exists. It relaunches only from the source's settled cut, and Core does not check that cut again. That cut is the diff --git a/packages/plugins/sdk/src/environment-tasks.ts b/packages/plugins/sdk/src/environment-tasks.ts index 9e288a2eb9d..ff2beb2c3c6 100644 --- a/packages/plugins/sdk/src/environment-tasks.ts +++ b/packages/plugins/sdk/src/environment-tasks.ts @@ -194,8 +194,7 @@ export const environmentTaskResultSchema = z.discriminatedUnion("kind", [ z.object({ kind: z.literal("admission_rejected"), taskId: providerId, reason: z.enum(["session_state_unavailable", "account_binding_mismatch"]) }).strict(), z.object({ kind: z.literal("released"), taskId: providerId }).strict(), - z.object({ kind: z.literal("resume"), taskId: providerId, outcome: z.enum(["resumed", "unavailable"]), runner: runnerArtifact.optional(), - archivedState: z.record(z.string(), z.unknown()).optional() }).strict(), + z.object({ kind: z.literal("resume"), taskId: providerId, outcome: z.enum(["resumed", "unavailable"]), runner: runnerArtifact.optional() }).strict(), z.object({ kind: z.literal("ownership"), taskId: providerId, @@ -307,8 +306,7 @@ export function parseEnvironmentTaskResult(operation: PluginEnvironmentTaskOpera const expected = operation.kind === "release" ? "released" : operation.kind === "resume" ? "resume" : operation.kind === "read_file" ? "file" : operation.kind === "describe" ? "description" : operation.kind === "prepare" ? "prepared" : operation.kind === "check_project_auth" ? "project_auth" : ["read_state", "archive_state"].includes(operation.kind) ? "state" : ["status", "connection", "credentials", "copilot_metadata"].includes(operation.kind) ? operation.kind : "accepted"; const rejectedSubmit = operation.kind === "submit" && result.kind === "admission_rejected"; if (result.taskId !== taskId || (result.kind !== expected && !rejectedSubmit)) throw new Error("Invalid plugin-provided Runner execution response"); - if (operation.kind === "resume" && result.kind === "resume" && (operation.runner - ? result.outcome === "resumed" && !result.runner : result.archivedState !== undefined)) { + if (operation.kind === "resume" && result.kind === "resume" && operation.runner && result.outcome === "resumed" && !result.runner) { throw new Error("Invalid plugin-provided Runner execution response"); } return result; diff --git a/packages/plugins/sdk/tests/environment-task-release-resume.test.ts b/packages/plugins/sdk/tests/environment-task-release-resume.test.ts index 81f3ed7cb8f..50bcc60b9f0 100644 --- a/packages/plugins/sdk/tests/environment-task-release-resume.test.ts +++ b/packages/plugins/sdk/tests/environment-task-release-resume.test.ts @@ -94,7 +94,7 @@ describe("release and resume task contract", () => { expect(environmentTaskResultSchema.safeParse({ ...result, runner: { ...runner, extra: true } }).success).toBe(false); }); - it("relaunches as the claimant's identity only when asked, and reports the archived state", () => { + it("relaunches as the claimant's identity only when asked, and reports the build", () => { expect(environmentTaskResultSchema.parse({ ...description, resumeIdentityVersion: 1 })).toEqual({ ...description, resumeIdentityVersion: 1 }); expect(environmentTaskResultSchema.safeParse({ ...description, resumeIdentityVersion: 2 }).success).toBe(false); const runner = { runId: "claimant-run", turnId: "turn-claimant-run", itemId: "item-claimant-run" }; @@ -104,13 +104,11 @@ describe("release and resume task contract", () => { expect(environmentTaskOperationSchema.safeParse({ ...resume, runner: changed }).success).toBe(false); } const build = { version: "0.4.1", digest: `sha256:${"b".repeat(64)}` }; - const archivedState = { schema: "paperclip.runner.durable.state.v1", ...identity, lifecycle: "ready" }; - const resumed = { kind: "resume", taskId: "task", outcome: "resumed", runner: build, archivedState }; + const resumed = { kind: "resume", taskId: "task", outcome: "resumed", runner: build }; expect(parseEnvironmentTaskResult(relaunch, "task", resumed)).toEqual(resumed); - const { archivedState: _archivedState, ...withoutState } = resumed; - expect(parseEnvironmentTaskResult(relaunch, "task", withoutState)).toEqual(withoutState); + const archivedState = { schema: "paperclip.runner.durable.state.v1", ...identity, lifecycle: "ready" }; + expect(() => parseEnvironmentTaskResult(relaunch, "task", { ...resumed, archivedState })).toThrow(); expect(() => parseEnvironmentTaskResult(relaunch, "task", { ...resumed, runner: undefined })).toThrow(); - expect(() => parseEnvironmentTaskResult(resume, "task", resumed)).toThrow(); expect(parseEnvironmentTaskResult(relaunch, "task", { kind: "resume", taskId: "task", outcome: "unavailable" })) .toEqual({ kind: "resume", taskId: "task", outcome: "unavailable" }); }); diff --git a/server/src/services/native-runtime/plugin-runner-release-resume.integration.test.ts b/server/src/services/native-runtime/plugin-runner-release-resume.integration.test.ts index 91ee51fe91b..64f62c73e3f 100644 --- a/server/src/services/native-runtime/plugin-runner-release-resume.integration.test.ts +++ b/server/src/services/native-runtime/plugin-runner-release-resume.integration.test.ts @@ -248,7 +248,7 @@ describeEmbeddedPostgres("plugin Runner release/resume through the Core executio await waitForCondition("parked Runner stopped", () => handle!.isExitConfirmed?.() === true); const identity = { ...operation.identity, ...operation.runner }; const archived = join(runnerRoot, `archived-${operation.identity.runId}.json`); - const archivedState = await state(); + const parkedState = await state(); await rename(join(runnerRoot, "runner-state.json"), archived); const launch = submittedLaunch!.launch!; listenPath = `/api/runner/v1/connect/${identity.runId}`; @@ -260,8 +260,8 @@ describeEmbeddedPostgres("plugin Runner release/resume through the Core executio ...(harness === "claude" ? { acpxLaunchProfile: { authorityDigest: `sha256:${sha("fixture authority")}`, command: sidecar, commandSha256: `sha256:${sha(await readFile(sidecar, "utf8"))}`, sidecarScript, sidecarScriptSha256: `sha256:${sha(await readFile(sidecarScript, "utf8"))}` } } : {}) }); - relaunches.push({ source: operation.identity, runId: identity.runId, archivedRunId: archivedState.runId }); - return { kind: "resume", taskId, outcome: "resumed", runner: artifact, archivedState }; + relaunches.push({ source: operation.identity, runId: identity.runId, archivedRunId: parkedState.runId }); + return { kind: "resume", taskId, outcome: "resumed", runner: artifact }; } if (operation.kind === "resume") { expect(relaunch).toBe(false); diff --git a/server/src/services/native-runtime/plugin-runner-task.test.ts b/server/src/services/native-runtime/plugin-runner-task.test.ts index 4225721a1d4..5102247bb69 100644 --- a/server/src/services/native-runtime/plugin-runner-task.test.ts +++ b/server/src/services/native-runtime/plugin-runner-task.test.ts @@ -799,8 +799,6 @@ describe("plugin Runner relaunch as the claimant run", () => { const next = { ...source, runId: "next-run", turnId: "turn-next-run", itemId: "item-next-run" }; const parked = { version: "0.4.0", digest: `sha256:${"c".repeat(64)}` }; const build = { version: "0.4.1", digest: `sha256:${"b".repeat(64)}` }; - const settledCut = { schema: "paperclip.runner.durable.state.v1", ...source, lifecycle: "ready", nextSourceSeq: 4, ackedSourceSeq: 3, - outbox: [], pendingTerminalDelivery: null, processedCommands: {} }; const base = { taskId: "task", projectIds: ["00000000-0000-4000-8000-000000000001"], projectAuthCheckVersion: 1 as const, harness: "codex", warmTaskVersion: 1 as const, releaseResumeVersion: 1 as const, accountIdentity: "selected-account", credentialIdentity: "selected-credential" }; const relaunchSpec = (): RunnerProcessLaunchSpec => { @@ -826,7 +824,7 @@ describe("plugin Runner relaunch as the claimant run", () => { it("starts the stopped Runner again as the claimant run and accepts the reported build", async () => { const { owner, task, authority, registration } = await relaunchOwner( - () => ({ kind: "resume", taskId: "task", outcome: "resumed", runner: build, archivedState: settledCut })); + () => ({ kind: "resume", taskId: "task", outcome: "resumed", runner: build })); expect(owner.driver.relaunchReleasedRunner).toEqual(source); expect(owner.driver.adoptExistingRunner).toBeUndefined(); expect(owner.relaunchMayHaveStarted()).toBe(false); @@ -850,7 +848,7 @@ describe("plugin Runner relaunch as the claimant run", () => { it("relaunches through a new owner, as after a Core restart, without submitting or adopting", async () => { const { owner, task, authority, registration } = await relaunchOwner( - () => ({ kind: "resume", taskId: "task", outcome: "resumed", runner: build, archivedState: settledCut }), + () => ({ kind: "resume", taskId: "task", outcome: "resumed", runner: build }), { resumeIdentityVersion: 1, fresh: true }); expect(task.mock.calls.find(([operation]) => operation.kind === "prepare")?.[0]).toMatchObject({ priorIdentity: source }); expect(owner.driver.relaunchReleasedRunner).toEqual(source); @@ -876,7 +874,7 @@ describe("plugin Runner relaunch as the claimant run", () => { let attempts = 0; const { task, registration, owner } = await relaunchOwner(() => { if (attempts++ === 0) throw new Error("fixture resume reply lost"); - return { kind: "resume", taskId: "task", outcome: "resumed", runner: build, archivedState: settledCut }; + return { kind: "resume", taskId: "task", outcome: "resumed", runner: build }; }); owner.launcher(relaunchSpec()); registration.activate(); @@ -888,16 +886,6 @@ describe("plugin Runner relaunch as the claimant run", () => { } finally { await registration.release("detach"); } }); - it("takes the provider's resumed answer without re-checking its archived state", async () => { - const { authority, registration, owner } = await relaunchOwner(() => ({ kind: "resume", taskId: "task", outcome: "resumed", - runner: build, archivedState: { ...settledCut, outbox: [{ sourceSeq: 4 }] } })); - owner.launcher(relaunchSpec()); - registration.activate(); - try { - await registration.ready(); - expect(authority.acceptRelaunchedRunner).toHaveBeenCalledExactlyOnceWith("synthetic-ticket", build, parked); - } finally { await registration.release("detach"); } - }); it("reports an unavailable relaunch for ordinary recovery", async () => { const { registration, owner } = await relaunchOwner(() => ({ kind: "resume", taskId: "task", outcome: "unavailable" })); diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 36e0f356584..bef1cc66288 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -13,7 +13,7 @@ "packages/plugins/sdk/src/environment-stop-error.ts": "b0e03f8aa2b2170ba095da5c7138050fced3f3cb", "packages/plugins/sdk/src/environment-sync-error.ts": "7d6a51a95da49a7da4525aebbab6382dc5c44ae8", "packages/plugins/sdk/src/environment-task-error.ts": "98aae8a06743b38884b68cb9a3ec44c57b34c0e4", - "packages/plugins/sdk/src/environment-tasks.ts": "9e288a2eb9d5c396244feb247f09c570b5b0f621", + "packages/plugins/sdk/src/environment-tasks.ts": "ff2beb2c3c6af2e6b84bad8701367d8aee3c755d", "packages/plugins/sdk/src/host-client-factory.ts": "e0301c390ea13f2340b669383f07af2455e48c8a", "packages/plugins/sdk/src/idle-drain.test.ts": "cc59f7881e7d46c89395a1d93d74f6c6b9b0a64a", "packages/plugins/sdk/src/idle-drain.ts": "ae6e4c6be4657a3d541396922b3bc551b8db557f",