refactor(runner): remove the unused plugin task source recovery path (#23590)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - An agent run uses a Runner task that an environment plugin provides.
When a Runner stops, the next run can need its saved session
> - #19134 and #19196 added one way to do this. The next run claims the
stopped Runner's task, and then starts that task again under its own
control
> - Those pull requests added the claim and its checks. They did not add
a caller. #19157 was to add the caller, and it did not merge
> - Nothing on `master` calls the claim. No lease gets the two records
that the claim writes, so every check of those records does nothing
> - The unused path still looks active. A reader can change it, and can
think that the change fixes a failure
> - This pull request removes the claim and all code that only reads its
records
> - The benefit is that the code shows only the recovery paths that can
run

## Linked Issues or Issue Description

Refs #19134, #19196 (added the path), #19157 (closed draft that called
it).

**Issue type**

Dead code

**What happened?**

`claimPluginTaskSourceRecovery` has no caller on `master`. Only the
claim writes `runnerTaskSourceConsumer` and `runnerTaskSourceRecovery`
to a lease. Six other server files read those records.

**Expected behavior**

The server contains only recovery code that can run.

**Steps to reproduce**

1. Run `git grep claimPluginTaskSourceRecovery master -- server`.
2. See only the definition.
3. Run `git log -G claimPluginTaskSourceRecovery master`.
4. See that the commits added the path, and later removed its tests. No
commit added a caller.

## What Changed

- Removed the source recovery claim and its checks
(`plugin-task-source-recovery.ts`).
- Removed the special handling of a claimed source from plugin task
dispatch, task resume, checkpoint writes, task ownership, and retained
and warm sandbox expiry.
- A Runner task owner no longer takes `codexSourceRecoveryVersion`.
Nothing set it, so the owner always refused to prepare a predecessor's
launch. It still refuses.
- The checkpoint writer still locks both runs, and still refuses a late
write from a session that moved to another task.
- The plugin SDK still accepts `codexSourceRecoveryVersion` and
`acpxSourceRecoveryVersion`, so a plugin that sends them does not fail.
The guide now says that Core does not use them.
- The Runner package does not change.

## Verification

- `npx vitest run` on eight test files for the changed code: 319 tests
pass.
- `npx tsc --noEmit` in `server` has no errors.
- The test of a late write to a retired checkpoint used the removed
records. It now uses the records of a session that moved to another
task.
- Not run locally: the suites that start a real Runner. CI runs them.

## Risks

- No production code wrote these records, so no saved lease should
contain them. A lease that does contain them is no longer held by them.
- #19157 depended on this path. It is closed and did not merge.
- No migration. No change to the plugin or Runner protocol.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code, with
extended thinking, tool use and code execution.

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

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nicky LeachandClaude Opus 5.5 authored and GitHub committed 2026-12-03 07:43:49 -08:00
1 parent 0134081be8
commit dc16c47362
12 files changed
+36 -394

No files matched your search

@@ -59,21 +59,16 @@ describe("plugin native Runner ownership", () => {
it("publishes current trusted recovery authority through warm owner rebind", () => {
const { task } = provider();
const input = { taskId: "task", task, projectIds: [], harness: "codex", authorityRunId: "first-owner", codexSourceRecoveryVersion: 1 as const, adoptIdentity: requirements.identity };
const input = { taskId: "task", task, projectIds: [], harness: "codex", authorityRunId: "first-owner", adoptIdentity: requirements.identity };
const owner = createPluginRunnerTaskOwner(input);
expect(owner.driver.authorityRunId).toBe("first-owner");
expect(owner.driver.codexSourceRecoveryVersion).toBe(1);
owner.rebind({ ...input, authorityRunId: "next-owner", codexSourceRecoveryVersion: undefined });
owner.rebind({ ...input, authorityRunId: "next-owner" });
expect(owner.driver.authorityRunId).toBe("next-owner");
expect(owner.driver.codexSourceRecoveryVersion).toBeUndefined();
});
it.each(["capability", "source", "identity", "account", "provider", "adoption"])("refuses an unqualified predecessor preparation: %s", async mode => {
it.each(["codex", "claude"])("refuses to prepare a predecessor's %s launch", async harness => {
const { task } = provider();
const owner = createPluginRunnerTaskOwner({ taskId: "task", task, projectIds: [], harness: mode === "provider" ? "claude" : "codex",
authorityRunId: "next", codexSourceRecoveryVersion: mode === "capability" ? undefined : 1,
resumeFrom: mode === "source" ? undefined : "source-task", priorIdentity: mode === "identity" ? undefined : requirements.identity,
accountIdentity: mode === "account" ? undefined : "selected-account", ...(mode === "adoption" ? { adoptIdentity: requirements.identity } : {}),
});
const owner = createPluginRunnerTaskOwner({ taskId: "task", task, projectIds: [], harness, authorityRunId: "next",
resumeFrom: "source-task", priorIdentity: requirements.identity, accountIdentity: "selected-account" });
await expect(prepare(owner)).rejects.toThrow("source reconciliation unavailable");
expect(task).not.toHaveBeenCalled();
});
@@ -88,7 +83,7 @@ describe("plugin native Runner ownership", () => {
expect(task.mock.calls.map(([operation]) => operation.kind)).toEqual(["check_project_auth"]);
} finally { context.finish(); }
});
it.each(["same-run", "suspended-predecessor"])("keeps ordinary %s preparation independent of predecessor capability", async mode => {
it.each(["same-run", "suspended-predecessor"])("keeps ordinary %s preparation", async mode => {
const { task } = provider();
const identity = mode === "same-run" ? requirements.identity : { ...requirements.identity, runId: "next" };
const owner = createPluginRunnerTaskOwner({ taskId: "task", task, projectIds: [], harness: "codex", projectAuthCheckVersion: 1,
@@ -110,28 +105,6 @@ describe("plugin native Runner ownership", () => {
expect(task.mock.calls.map(([op]) => op).filter(op => op.kind === "prepare").at(-1)).toMatchObject({ resumeFrom: "source-task" });
} finally { await registration.release("detach"); }
});
it("prepares and submits exact A, then prepares B without copying or reconciling A again", async () => {
const { task } = provider();
const owner = createPluginRunnerTaskOwner({ taskId: "task", task, projectIds: [], harness: "codex", projectAuthCheckVersion: 1, pollMs: 1,
authorityRunId: "next", codexSourceRecoveryVersion: 1, resumeFrom: "source-task", priorIdentity: requirements.identity,
accountIdentity: "selected-account" });
await expect(prepare(owner, { ...requirements, identity: { ...requirements.identity, runId: "foreign" } })).rejects.toThrow("source reconciliation unavailable");
await prepare(owner);
const registration = await owner.registration({} as never, "run");
try {
owner.launcher(launchSpec());
await vi.waitFor(() => expect(task.mock.calls.some(([op]) => op.kind === "submit")).toBe(true));
const initial = task.mock.calls.map(([op]) => op).filter(op => ["prepare", "submit"].includes(op.kind));
expect(initial).toEqual([expect.objectContaining({ kind: "prepare", resumeFrom: "source-task", requirements: expect.objectContaining({ identity: requirements.identity }) }),
expect.objectContaining({ kind: "submit", resumeFrom: "source-task", runner: expect.objectContaining({ runId: "run", turnId: "turn", itemId: "item" }) })]);
await prepare(owner);
expect(task.mock.calls.map(([op]) => op).filter(op => op.kind === "prepare").at(-1)).toMatchObject({ resumeFrom: "source-task" });
await prepare(owner, { ...requirements, identity: { ...requirements.identity, runId: "next", turnId: "next-turn", itemId: "next-item" } });
const attached = task.mock.calls.map(([op]) => op).filter(op => op.kind === "prepare").at(-1);
expect(attached).toMatchObject({ priorIdentity: requirements.identity, requirements: { identity: { runId: "next" } } });
expect(attached).not.toHaveProperty("recoveryPurpose"); expect(attached).not.toHaveProperty("resumeFrom");
} finally { await registration.release("detach"); }
});
it.each(["finish", "rebind"])("does not send startup Stop after the context %s", mode => {
const context = new NativeExecutionContext({ binding: { companyId: "company", agentId: "agent", runId: "run" } } as never, 1_000);
const next = new NativeExecutionContext(context.execution, 1_000);