Commit Graph
2 Commits
Author SHA1 Message Date
DottaandClaude Opus 5.5 9b16044bf1 fix(cloud): move idle local workspaces in the online durable-data pass (#22270)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A hosted server can move to volume-free storage only when no durable
data stays on its local volume
> - The online durable-data pass moves that data while the server keeps
serving, one bounded and resumable pass at a time
> - The pass does not move local execution workspaces, so servers with
local workspaces stay ineligible (`workspaces_require_migration`)
> - Online-safe owners for workspaces already exist: the online remote
workspace migration and the online workspace operation reconciliation
> - This pull request adds workspace phases to the pass that call those
owners, and defers busy or unsupported workspaces with a reason
> - The benefit is that idle workspaces move with no outage, and
operators can see which workspaces cannot move and why

## Linked Issues or Issue Description

**What happened?**
The online durable-data pass never moves local execution workspaces. A
server with local workspaces keeps the `workspaces_require_migration`
blocker after every pass.

**Expected behavior**
The pass moves each idle local workspace to shared storage through the
online owner. It defers a busy or unsupported workspace and reports the
reason.

**Steps to reproduce**
1. Run the online durable-data pass on a server that has a local
`local_fs` execution workspace.
2. Read the pass result and the eligibility blockers.
3. The workspace stays local and `workspaces_require_migration` stays.

**Deployment mode**
Hosted server that moves from a local volume to volume-free storage.

## What Changed

- Add two phases to the online durable-data pass, after
`runtime_skill_assets` and before the native phases:
- `workspace_operations`: pages companies that have local workspaces and
calls `reconcileOnlineWorkspaceOperations` for each. It counts
`workspaceOperations` and defers each held operation as
`workspace_operations:<reason>`.
- `workspaces`: pages local workspaces (same filter as the eligibility
check), deepest path first so nested workspaces go before their parents.
For each workspace it reads `inventoryRemoteWorkspaceMigration`. If the
workspace is eligible, it calls `migrateRemoteWorkspace` in online mode
(never `writersStopped`) with the pass signal and a 1 s source-lock
wait.
- A workspace that the owner refuses is deferred with each owner reason
as `workspaces:<reason>`, for example `workspaces:active_execution`,
`workspaces:task_binding_required`,
`workspaces:workspace_provider_unsupported`,
`workspaces:workspace_source_busy`, or `workspaces:execution_rows_busy`.
An unknown error becomes `workspaces:owner_failed` and its message is
not echoed. The page continues with the next workspace.
- Both phases use a cursor and a limit that the pass can halve after a
budget timeout, like the other phases.
- Add `listLocalWorkspaceCompanies` and `listLocalWorkspaces` next to
`localWorkspaceDependencyWhere`.
- The pass stops waiting for a workspace owner at the budget. It reports
`workspaces:owner_busy` until that owner settles.

## Verification

- `cd server && npx vitest run
src/services/online-durable-data-migration.test.ts
src/services/online-durable-data-migration-postgres.test.ts`
- Unit tests with injected owners: phase order, online mode and lock
wait, deferral codes, owner refusal under locks, cursor resume across
budget-limited calls, and page halving that keeps finished workspaces.
Seven tests fail without the change and pass with it.
- Embedded PostgreSQL test with the real owners: an idle managed-project
workspace moves to a committed snapshot and its files restore from it. A
workspace with a running task run is deferred as
`workspaces:active_execution`, and its record, files, and operations
stay unchanged. The test fails without the change and passes with it.
- Embedded PostgreSQL test for the workspace and company cursors: ten
workspaces in two companies, with equal and different path lengths,
across pages of three. Each workspace appears once, deepest first.
- `pnpm verify` selected 2934 of 3802 test files (almost the full
suite). It was not run to the end. Required CI covers the full suite.

## Risks

- A workspace move that takes longer than one pass budget (60 s) stops
at the budget. The workspace keeps its in-progress move marker, so new
runs for that workspace are refused until a later pass resumes the move.
The pass resumes the same page on the next call. If one workspace times
out twice at page size 1, the pass reports `workspaces:stalled` and goes
on; the next cycle resumes it again. A very large workspace can
therefore stay blocked for runs across passes. The operator online
workspace tool can resume it with a longer deadline.
- A workspace with no proven online source uses the owner's lifecycle
lock, which waits without a timeout. The pass does not wait for it past
the budget. The pass returns at the budget, and the owner stops at its
next abort check after it gets the lock. Until that owner settles, later
passes skip the workspace phase and report `workspaces:owner_busy`, so
two moves never run at the same time.
- Workspaces that can never move online (for example unsupported
providers or workspaces without a task binding) are reported each pass
and are not changed. This change makes no product decision for them.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with 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
- [ ] 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: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 19:35:56 -06:00
DottaandPaperclip aa2a7be8b4 fix: recognize provider-owned Runner workspace storage (#20663)
## Thinking Path

> - Paperclip manages agent work and preserves its execution state.
> - A server replacement must retain every workspace that depends on the
old server disk.
> - Runner task environments can own their workspace outside the Core
server.
> - These environments save an adapter-managed workspace with a
runnerTaskWorkspaceOwner binding.
> - Readiness and maintenance treated that provider path as a Core
filesystem dependency.
> - This change validates the saved owner and shares that classification
between both paths.
> - Local, malformed, and foreign workspace bindings still block
enrollment.

## Linked Issues or Issue Description

Related enrollment safeguards: #18835. A GitHub search found no
duplicate fix for this provider-owned class.

**What happened?**

Volume-free readiness returned workspaces_require_migration for an
adapter-managed Runner workspace owned by a plugin task environment.
Maintenance also selected it and failed with
workspace_provider_unsupported. The provider owned the path, which did
not exist on the Core server.

**Expected behavior**

A valid provider-owned workspace does not require migration from the
Core server disk. Ordinary local workspaces and invalid ownership
bindings remain blockers.

**Steps to reproduce**

1. Run a paperclip_runner agent in a plugin task environment.
2. Retain its adapter-managed workspace and complete
runnerTaskWorkspaceOwner binding.
3. Read startup eligibility for volume-free enrollment.
4. Observe the workspace blocker before this fix.
5. Run workspace maintenance and observe workspace_provider_unsupported
for the same row.

**Paperclip version or commit**

Reproduced on 353945c86d. The regression
also fails on the branch base a3b34a9d88.

**Deployment mode**

Docker with external PostgreSQL. Local regression coverage uses
disposable PostgreSQL.

## What Changed

- Share one metadata predicate between startup eligibility and offline
workspace migration selection.
- Validate a complete saved owner against a same-company
paperclip_runner agent and a plugin environment with matching nonempty
keys. Per-run environment overrides remain supported.
- Keep ordinary local workspaces and invalid ownership bindings in the
migration set.
- Add real PostgreSQL coverage for provider-owned readiness, zero-import
maintenance selection, unchanged retained rows, and
local/foreign/malformed ownership controls.

## Verification

- Readiness RED: the provider-owned fixture failed with
workspaces_require_migration on unchanged source.
- Maintenance RED: the provider-owned fixture failed with
workspace_provider_unsupported before the shared selector was applied.
- GREEN: 29 selected tests passed across three files. This covers 8
eligibility/configuration tests and 21 migration/offline-admission
cases, including eleven invalid/local owner controls inside the
eligibility test. The affected migration file has 207 cases; broad
coverage remains with required CI.
- Commands: `pnpm exec vitest run
server/src/__tests__/ephemeral-server-data.test.ts
server/src/__tests__/ephemeral-server-contract.test.ts` plus focused
selections in `server/src/services/remote-workspace-migration.test.ts`
for provider ownership, offline admission, local imports,
interrupted-batch resume, and unresolved workspace semantics.
- Server layered typecheck passed after the final source change.
- Final head `2fb98dbc664da14e6f60d812e1e10877b2b7f00a`: [required
CI](https://github.com/paperclipai/paperclip/actions/runs/42920262773)
completed with 55 successful checks, 1 neutral review, and 4 intended
skips. Greptile and Paperclip Review both rated this head 5/5. No
unresolved review threads remain.
- No hosted data migration or metadata rewrite was performed.

## Risks

- This changes a readiness classification. Incomplete, foreign,
non-Runner, or mismatched environment bindings remain conservative
blockers.
- The check validates saved ownership through current database bindings.
It does not inspect provider files or grant execution authority.
- Existing saved rows retain their shape. No migration or archive format
changes are required.

## Model Used

OpenAI Codex, GPT-6 family, with reasoning, repository tools, code
editing, and real PostgreSQL tests. The host does not expose the exact
model ID or context window size.

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-10 17:22:01 -06:00