Files
PaperClipAI/server
917a38efd7 fix(server): give the retired task workspace conflict a stable code (#23582)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Before a run starts, Paperclip reserves the task's remote workspace.
It refuses a workspace that is archived or whose cleanup failed, with
the message "Workspace ownership changed.".
> - When setup fails, the server sends a run-failure report to Sentry.
Since #23568, the report groups a setup conflict by the stable code in
its details.
> - This conflict has no code. Its reports use the fallback grouping and
share a Sentry group with other uncoded setup conflicts.
> - This pull request gives the conflict the code
`remote_workspace_retired`.
> - The benefit is a separate Sentry group for runs that fail on a
retired task workspace.

## Linked Issues or Issue Description

**What happened**
A task's execution workspace was archived. Automatic recovery then
started new runs for the task. Each run failed setup with "Workspace
ownership changed.". These reports went into a shared Sentry group with
unrelated setup conflicts, because the conflict had no code.

**Expected behavior**
The conflict has a stable code. Its run-failure reports get their own
Sentry group.

**Steps to reproduce**
1. Reserve a remote task workspace, then set its status to `archived` or
`cleanup_failed`.
2. Reserve the workspace again for a new run.
3. The reservation rejects with a 409 conflict that has no
`details.code`.

**Paperclip version or commit**
master at 8379dedd9.

Refs #23568 (reads `details.code` for run-failure grouping).

## What Changed

- `remote-workspaces.ts`: the "Workspace ownership changed." conflict
now has `details.code` `remote_workspace_retired`. The message and the
409 status do not change.
- `remote-workspaces.integration.test.ts`: a new test reserves an
`archived` and a `cleanup_failed` workspace and expects the conflict
with the new code.
- `run-failure-sentry.test.ts`: the example of an uncoded conflict now
uses another conflict that still has no code.

## Verification

- `cd server && npx vitest run
src/services/remote-workspaces.integration.test.ts -t "stable conflict
code"`: 2 of 2 pass. Without the change to `remote-workspaces.ts`, both
fail.
- `npx vitest run src/services/remote-workspaces.integration.test.ts
src/__tests__/run-failure-sentry.test.ts
src/services/__tests__/run-failure-diagnostics.test.ts`: 301 of 302
pass. The one failure, "cleans saved reads with read-only folders", also
fails on unchanged master in my sandbox (file mode 256 instead of 292).
It is not related to this change.

## Risks

- Low risk. The message, the status and the control flow do not change.
Only the conflict details get a code.
- Expected change: after deploy, Sentry reports for this conflict move
to a new group.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution
in a sandbox.

## 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
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 22:13:09 -08:00
..