Files
PaperClipAI/server
c2e7df2dcc fix(workspaces): use project storage for a fresh retry after unowned task storage (#20756)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A project can use a storage provider plugin. That plugin prepares
each task's git worktree
> - A board Retry after a failed run can start a fresh attempt. The
fresh attempt starts from the project source
> - `preparePluginWorkspace` returns `null` when the task is still bound
to a workspace that no storage provider owns. It does this also for a
fresh attempt
> - On a plugin task environment, the host then reserves an empty
adapter-managed "Fresh task workspace" with no repository. The runner
fails in it. The next Retry finds that empty workspace bound to the
task, returns `null` again and reserves another empty workspace. The
task can never start again
> - This pull request lets a fresh attempt use the project storage
provider even when the previous workspace is not provider-owned
> - The benefit is that one Retry gives the task a normal provider
worktree again

## Linked Issues or Issue Description

**What happened?**
Tasks moved off an older execution environment kept a binding to a
workspace that no storage provider owned. A board Retry selected
`fresh_isolated_workspace`. `preparePluginWorkspace` returned `null`
because the bound workspace was not plugin-owned. The host fell back to
`reserveFreshPluginTaskWorkspace`, which made an empty `adapter_managed`
workspace (strategy `project_primary`, no repository, no recovery
snapshots). The run failed in about one second with "Plugin-provided
Runner execution operation unavailable; reconcile the same task before
retrying". Each later Retry made another empty workspace, chained to the
last one.

**Steps to reproduce**
1. Use a project with a storage provider plugin that supports fresh
workspaces.
2. Bind a task to a workspace that the provider does not own (for
example an adapter-managed workspace).
3. Call `preparePluginWorkspace` for a fresh attempt with that workspace
as the previous workspace.

**Expected behavior**
The storage provider prepares a new worktree for the fresh attempt.

**Actual behavior**
`preparePluginWorkspace` returns `null` and never calls the provider.

## What Changed

- `server/src/services/plugin-workspaces.ts`: the early `return null`
for a previous workspace that no provider owns no longer applies to a
fresh attempt. The fresh attempt then uses the project's storage
provider, as for a task with no bound workspace.
- `server/src/__tests__/plugin-fresh-workspaces.integration.test.ts`:
new test "prepares provider storage for a fresh retry that follows a
workspace the provider does not own".

## Verification

- The first commit adds only the test. CI on that commit (`d09ad235`,
[failed
job](https://github.com/paperclipai/paperclip/actions/runs/42976154239/job/130393285731))
shows only this test fail on the current code (`preparePluginWorkspace`
returns `null`).
- The second commit adds the fix. CI shows the test pass.
- The other tests in the file keep the fresh-attempt guarantees: an
older provider still fails closed, a changed binding revision still
stops the call, and a lost reply still reconciles to the same operation.
- I did not run the suite locally. The test needs embedded Postgres, and
this environment does not install packages. CI runs it.

## Risks

- Low to medium risk. A fresh attempt in a project with a storage
provider now uses that provider even when the previous workspace was
local or adapter-managed. Before, such an attempt used the fallback
path. This matches the project's storage policy, and a fresh attempt
does not reuse the previous workspace's files.
- Projects without a storage provider are not affected: the function
still returns `null` for them.
- Non-fresh preparation is not affected.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use
(shell, file edits). Standard reasoning mode.

## 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
- [ ] 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: lucktastic <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:10:25 -08:00
..