paperclip/packages/adapter-utils/src
Dotta 1dceee9a4e
fix(runner): persist warm Daytona workspaces (#12901)
## Thinking Path

> - Paperclip manages AI agent work and the execution state for each
task.
> - Remote agents run in sandbox environments such as Daytona.
> - Daytona keeps files while a sandbox is stopped, but deletion removes
those files.
> - Runner Codex did not copy successful remote workspace changes back
to the host workspace.
> - A warm sandbox could therefore hide data loss until Daytona replaced
or deleted the sandbox.
> - This pull request makes the host workspace durable after every
successful turn and keeps verified reusable sandboxes warm.
> - The benefit is reliable multi-turn work across warm reuse, restart,
stop, and sandbox replacement.

## Linked Issues or Issue Description

**What happened?**

A successful native Codex turn in Daytona could leave workspace changes
only in the remote sandbox. A later warm turn appeared to work because
it reused that filesystem. A replacement sandbox could start from stale
host data and lose the successful changes.

**Expected behavior**

Paperclip must merge each successful remote turn into the authoritative
host workspace before it completes the run. A verified warm lease may
reuse its remote files. A replacement lease must reconstruct the exact
durable workspace seed.

**Steps to reproduce**

1. Run Codex in a reusable Daytona environment.
2. Write a file during one successful turn.
3. Replace the Daytona sandbox before the next turn.
4. Observe that the next turn can start without the prior file on the
unpatched code.

Related remote workspace foundation: #10070.

## What Changed

- Added explicit `host_current`, `durable_seed`, and `adopt_remote`
workspace preparation modes.
- Added atomic, versioned native workspace descriptors and seed archives
under `PAPERCLIP_HOME`.
- Added real native sandbox export and three-way host merge before
terminal result completion.
- Added workspace-only recovery after a proposed result. Recovery does
not submit another provider turn or consume the provider retry budget.
- Added fail-closed handling when a sandbox with unexported changes is
gone.
- Kept healthy reusable Daytona sandboxes started for legacy Codex and
Runner Codex.
- Kept the Runner Codex process and provider session across verified
warm turns.
- Added the paid `daytona-warm-continuity` browser suite. It contains
exactly the legacy Codex and Runner Codex cells. Each cell performs
three measured turns.
- Documented `pnpm test:e2e:runner -- --suite daytona-warm-continuity`.
No package script was added.
- Added no database migration. The metadata format is backward
compatible and idempotent.

## Verification

- `pnpm typecheck`
- `pnpm test:e2e:runner:unit` — 114 passed
- Native workspace, finalizer, session, and environment tests — 232
passed
- Daytona provider tests — 150 passed
- Workspace staging and merge tests — 98 passed
- Runner transport tests — 63 passed
- Legacy Codex restore tests — 5 passed
- Rust format and compile checks pass through root typecheck
- The paid Daytona suite was not run locally because the required
Daytona, OpenAI, and immutable image credentials are not present.

## Risks

- The main risk is an incorrect workspace identity or merge after a
crash. Durable descriptors bind the run, workspace, lease, provider
lease, local root, remote root, and baseline digest. Ambiguous evidence
fails closed.
- The host merge may conflict with concurrent host edits. The existing
three-way merge and exclusion rules handle this case and surface
failures.
- A deleted sandbox cannot recover unexported bytes. Paperclip now
blocks with `workspace_sync_out_unrecoverable` instead of reporting
success or rerunning the provider.
- There is no database migration. Descriptor writes and recovery are
atomic and idempotent.

## Model Used

OpenAI Codex with GPT-5. The run used agentic reasoning, repository
inspection, code execution, test execution, Git, and GitHub CLI tools.

## 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
2026-09-05 13:00:57 -05:00
..
acpx-engine feat(runner): bind ACPX profile boundary (#12387) 2026-08-30 12:37:13 -05:00
test-support feat(mcp) [split 4/8]: wire gateway runtime and Smoke Lab (#9559) 2026-07-14 15:07:30 -05:00
billing.test.ts feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
billing.ts feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
bridge-transport-contract.ts refactor(adapter-utils): remove the retired duplex_v1 sandbox bridge transport (#12171) 2026-08-25 08:47:43 -07:00
command-managed-runtime.test.ts Write mode-constrained inbound files directly to their target (#12320) 2026-08-27 10:54:11 -07:00
command-managed-runtime.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
command-redaction.test.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
command-redaction.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
duplex-frame-codec.test.ts refactor(adapter-utils): delete the dead duplex body-chunk protocol code (#12186) 2026-08-25 14:33:38 -07:00
duplex-frame-codec.ts refactor(adapter-utils): replace the process-wide byte ledger with route-local byte bounds (#12465) 2026-08-28 14:36:18 -07:00
duplex-frame-vectors.json refactor(adapter-utils): replace the process-wide byte ledger with route-local byte bounds (#12465) 2026-08-28 14:36:18 -07:00
duplex-observability.test.ts feat(duplex): run the Daytona sandbox callback bridge over Node HTTP/2 (#12120) 2026-08-25 07:35:39 -07:00
duplex-observability.ts refactor(adapter-utils): replace the process-wide byte ledger with route-local byte bounds (#12465) 2026-08-28 14:36:18 -07:00
env-bindings.test.ts fix(adapters): keep user-scoped env bindings on the agent Test action (#10926) 2026-08-05 17:18:41 -07:00
env-bindings.ts fix(adapters): keep user-scoped env bindings on the agent Test action (#10926) 2026-08-05 17:18:41 -07:00
exclude-patterns.ts Fix sandbox git publishing and large workspace uploads (#8422) 2026-06-20 22:03:55 -07:00
execution-target-sandbox.test.ts feat(runner): add remote execution substrate (#12638) 2026-09-01 01:29:06 -05:00
execution-target-stdin-race.test.ts fix(adapter-utils): allow process sessions without birthtime (#12451) 2026-08-28 10:33:22 -07:00
execution-target.test.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
execution-target.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
git-workspace-sync.test.ts fix(adapter-utils): harden the referenced-project ignore scan (#12214) 2026-08-26 08:30:42 -07:00
git-workspace-sync.ts fix(adapter-utils): harden the referenced-project ignore scan (#12214) 2026-08-26 08:30:42 -07:00
http2-bridge-server.test.ts refactor(adapter-utils): replace the process-wide byte ledger with route-local byte bounds (#12465) 2026-08-28 14:36:18 -07:00
http2-bridge-server.ts refactor(adapter-utils): replace the process-wide byte ledger with route-local byte bounds (#12465) 2026-08-28 14:36:18 -07:00
index.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
local-process-sandbox.test.ts fix(adapter-utils): keep sandbox proxy sockets within Linux path limit (#10221) 2026-07-26 10:52:16 -05:00
local-process-sandbox.ts fix(adapter-utils): keep sandbox proxy sockets within Linux path limit (#10221) 2026-07-26 10:52:16 -05:00
log-redaction.ts fix(ui): external adapter selection, config field placement, and transcript parser freshness 2026-04-03 21:11:22 +01:00
login-capability.test.ts feat(login): use the login pseudo-terminal for Codex device login and de-Claude the shared channel (#12020) 2026-08-23 09:44:59 -07:00
login-capability.ts feat(login): use the login pseudo-terminal for Codex device login and de-Claude the shared channel (#12020) 2026-08-23 09:44:59 -07:00
login-pty-transport.test.ts feat(login): use the login pseudo-terminal for Codex device login and de-Claude the shared channel (#12020) 2026-08-23 09:44:59 -07:00
login-pty-transport.ts feat(login): use the login pseudo-terminal for Codex device login and de-Claude the shared channel (#12020) 2026-08-23 09:44:59 -07:00
login-runner-lifecycle.test.ts feat(auth): normalize agent login in the sandbox onto one session table and a capability contract (#11730) 2026-08-19 11:51:31 -07:00
login-runner-lifecycle.ts feat(auth): normalize agent login in the sandbox onto one session table and a capability contract (#11730) 2026-08-19 11:51:31 -07:00
mcp-isolation.integration.test.ts feat(skills): import skills from projects (#9620) 2026-07-15 18:01:44 -05:00
paperclip-runner-permissions.test.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
paperclip-runner-permissions.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
published-exports.test.ts refactor: disambiguate the Telemetry and Observability data paths (#12128) 2026-08-24 16:42:33 -07:00
remote-execution-env.ts Sanitize remote execution envs at the boundary (#5325) 2026-05-05 19:30:14 -07:00
remote-managed-runtime.test.ts fix(adapter-utils): harden the referenced-project ignore scan (#12214) 2026-08-26 08:30:42 -07:00
remote-managed-runtime.ts fix(adapter-utils): honor .gitignore for referenced-project staging (#12184) 2026-08-25 14:22:47 -07:00
runner-connectivity.test.ts Unify Paperclip Runner experimental controls (#12666) 2026-09-01 09:21:23 -05:00
runner-connectivity.ts Unify Paperclip Runner experimental controls (#12666) 2026-09-01 09:21:23 -05:00
runtime-progress.test.ts feat(environments): refer to the managed default environment by name, not the sandbox driver key (#11838) 2026-08-21 12:51:22 -07:00
runtime-progress.ts feat(environments): refer to the managed default environment by name, not the sandbox driver key (#11838) 2026-08-21 12:51:22 -07:00
sandbox-callback-bridge.test.ts perf(gateway): remove the whole-body string round trip on the HTTP/2 send path (#12189) 2026-08-25 14:56:17 -07:00
sandbox-callback-bridge.ts perf(gateway): remove the whole-body string round trip on the HTTP/2 send path (#12189) 2026-08-25 14:56:17 -07:00
sandbox-file-sync.test.ts fix(adapter-utils): honor .gitignore for referenced-project staging (#12184) 2026-08-25 14:22:47 -07:00
sandbox-install-command.test.ts fix(build): enforce Node 24 across Paperclip (#11792) 2026-08-21 10:17:52 -07:00
sandbox-install-command.ts fix(build): enforce Node 24 across Paperclip (#11792) 2026-08-21 10:17:52 -07:00
sandbox-managed-runtime.test.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
sandbox-managed-runtime.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
sandbox-run-log-stream.ts Improve live agent feedback during sandboxed runs (#8915) 2026-07-02 22:21:56 -07:00
sandbox-shell.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
server-utils-env.test.ts fix: preserve control plane access in Codex sandbox (#10152) 2026-07-24 15:25:59 -05:00
server-utils.test.ts feat(runner): add Codex-native application integration (#12591) 2026-08-31 14:38:38 -05:00
server-utils.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
session-compaction.ts feat: add kimi-local adapter for Kimi Code CLI (CLI + ACP engines) (#9967) 2026-08-20 12:06:33 -07:00
skill-library-manifest.test.ts feat: agents see the company skill library at runtime (#12147) 2026-08-25 14:01:52 -07:00
skill-library-manifest.ts feat: agents see the company skill library at runtime (#12147) 2026-08-25 14:01:52 -07:00
ssh-fixture.test.ts fix(adapter-utils): make SSH env-lab fixture teardown deterministic (#12238) 2026-08-26 14:03:47 -07:00
ssh.ts fix(adapter-utils): make SSH env-lab fixture teardown deterministic (#12238) 2026-08-26 14:03:47 -07:00
sync-operation-schedule.test.ts feat: parallelize sandbox file-sync behind a provider opt-in capability (#11736) 2026-08-19 12:34:11 -07:00
sync-operation-schedule.ts feat: parallelize sandbox file-sync behind a provider opt-in capability (#11736) 2026-08-19 12:34:11 -07:00
types.ts fix(runner): restore local session and task integrity (#12721) 2026-09-02 16:11:26 -05:00
workspace-restore-merge.test.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
workspace-restore-merge.ts fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
workspace-restore-teardown.test.ts refactor(adapter-utils): extract the shared workspace-restore teardown factory (#12196) 2026-08-25 21:38:27 -07:00
workspace-restore-teardown.ts refactor(adapter-utils): extract the shared workspace-restore teardown factory (#12196) 2026-08-25 21:38:27 -07:00