Commit Graph
2 Commits
Author SHA1 Message Date
Nicky LeachandClaude Opus 5.5 dc16c47362 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>
2026-12-03 07:43:49 -08:00
Nicky LeachandPaperclip a924d2e2c7 Persist portable Runner ownership through controller recovery (#21066)
## Thinking Path

> - Paperclip delegates remote Runner execution to environment plugins.
> - A plugin can move a session to another task allocation.
> - The Core controller can lose an ownership reply or restart before
the Runner starts.
> - The source and target need a durable record of the same request.
> - This change binds restart and attachment to that request and the
original unlaunched task lease.

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Recovery of plugin Runner sessions on replacement compute.

**Current behavior**
Core cannot replay a session ownership request from saved lease state
during startup.

**Proposed behavior**
Record the operation on both leases and check the matched ownership
receipt before attaching. Preserve the original pre-admission lease
across controller restart.

Managed environment configuration is in
[#21065](https://github.com/paperclipai/paperclip/pull/21065). Related
warm sandbox cleanup is in
[#20065](https://github.com/paperclipai/paperclip/pull/20065). This
layer preserves the same-sandbox fallback from
[#21001](https://github.com/paperclipai/paperclip/pull/21001). Workspace
placement follows in
[#20743](https://github.com/paperclipai/paperclip/pull/20743).

## What Changed

- Add the optional `sessionHandoffVersion` capability and the ownership
task operation.
- Save matching ownership claims and fence source checkpoint access.
Replay a pending request on the original target.
- Restore a portable session using the durable claim and the current
credentials for the same account. Start a fresh conversation when the
provider reports an unavailable checkpoint, or when Core's persisted
compatibility decision selects a different session after transfer. The
latter requires an unlaunched target; subsequent recovery must match the
fresh task's saved identity. Both paths retain the workspace transfer
and source fencing.
- Reuse the original unlaunched task lease after hard or graceful
controller restart. After a move has attached, validate the surviving
Runner through the saved claim rather than requiring its logical lease
ID to equal the new physical lease.
- Keep older retained leases without a saved account identity on the
existing resume path.
- Apply the existing supported MCP-only compatibility rule to warm
recovery and predecessor accounting. Persist the capability discovered
at admission and reuse it after restart without repeating discovery.
- Keep predecessor-retirement fallback scoped to the same physical
sandbox. A refusal after a portable move preserves the session instead
of requesting a replacement that the plugin driver cannot enforce.

## Verification

- On `1eb527be27`, server typecheck (including Runner build and SDK
dependencies) passed.
- Independent final verification passed 168 tests across portable source
recovery, session resume, controller recovery, and task authority; two
existing tests were skipped. The full portable source integration suite
passed 64 tests.
- The new integration follows confirmed ownership through an
incompatible instruction change, persisted fresh admission, target-only
prepare/auth/submit without the source checkpoint, and reattachment
after controller replacement. It also rejects unpersisted session
selection, ambiguous target leases, and incorrect saved identities.
- Before this final change, independent verification passed 1,667 tests
across executor, session resume, recovery usage, remote warm recovery,
runtime selection, and runtime execution; the environment lifecycle
suite passed 208 tests.
- Existing regressions cover previous-release account metadata,
supported and unsupported MCP changes, provider/instruction
incompatibility, and admission capability reuse without another
discovery call.
- On `51d7eec373`, all four S3 multipart throttle tests passed
independently. CI exposed an existing timing-sensitive test twice; its
20 ms overlap assumption now uses synchronized retries and an event-loop
yield. Production upload code is unchanged. Temporary concurrency caps
of one and eight both fail the retained exact-four assertion.
- Exact SDK source-pin checks passed for both stack heads. The upper
#20743 code patch remains unchanged; its documentation preserves both
layers' behavior.

## Risks

- The handoff protocol is opt-in. Existing plugin leases without
portable ownership metadata keep the previous release's resume path.
Live attachment still requires end-to-end qualification. An unverified
claim blocks startup. Git workspaces prepared on a portable allocation
also need the workspace placement layer.

## Model Used

- OpenAI Codex GPT-6 with GPT-6.1 Sol agents for implementation and
independent review.

## Checklist

- [x] Thinking path and model are included.
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] The issue is described using the enhancement template.
- [x] Local checks passed and new behavior has tests.
- [x] All Paperclip CI gates are green.
- [x] Greptile is 5/5 with no open findings.

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-12 10:43:48 -08:00