refactor(plugin-sdk): remove archivedState from the resume result (#22443)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native Runner sessions can run in a remote environment task that a
plugin provider owns
> - A provider can relaunch a parked Runner as the next run, and it
reports the result to Core
> - The resume result could carry `archivedState`, so Core could check
that the park was a settled cut
> - #22442 makes the provider the authority on the park, and Core stops
reading `archivedState`
> - This pull request removes the field from the SDK result schema
> - The benefit is a smaller provider contract with no unused fields

## Linked Issues or Issue Description

Refs #22442

**What existing behavior does this improve?**

The environment task resume result contract in the plugin SDK.

**Subsystem affected**

`packages/plugins/sdk` (environment tasks), and the tests in
`server/src/services/native-runtime` that build resume results.

**Current behavior**

After #22442, a resumed relaunch result can carry an optional
`archivedState`. Core accepts it and does not read it.

**Proposed behavior**

The resume result has no `archivedState` field. The strict schema
refuses it.

**Reason and benefit**

The field has no reader. Removing it keeps the contract to the fields
that Core uses.

**Breaking changes**

A provider that still sends `archivedState` on a resume result fails the
schema check, and the relaunch fails. Deploy this with or after the
provider change that stops sending the field.

**Additional context**

Stacked on #22442.

## What Changed

- SDK: removed `archivedState` from the `resume` result schema, and
simplified the relaunch check in `parseEnvironmentTaskResult`.
- SDK test: a relaunch result with `archivedState` now fails; one
without it passes.
- `plugin-runner-task.test.ts`: removed the field from the fixtures, and
removed the test that checked Core ignores it.
- `plugin-runner-release-resume.integration.test.ts`: the fixture
provider no longer returns the field.
- `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`: removed the note about the
field.

## Verification

- `pnpm run typecheck` in `server` (builds all dependent packages):
pass.
- `pnpm vitest run
src/services/native-runtime/plugin-runner-task.test.ts` in `server`: 116
passed.
- `pnpm vitest run tests/environment-task-release-resume.test.ts` in
`packages/plugins/sdk`: 48 passed.
- I did not run the embedded-Postgres integration suite locally. CI runs
it.

## Risks

- A provider that still sends the field makes the relaunch fail. Deploy
this with or after the provider change that stops sending it. It can
ship in the same deploy as #22442.
- Low risk otherwise: the change removes an unused optional field.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use
(shell, file edit, code search). Extended thinking on.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-11-24 10:25:32 -08:00
1 parent 0b2acfb956
commit 3ca9b6d471
6 files changed
+14 -31

No files matched your search

@@ -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;
@@ -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" });
});