paperclip/packages/adapters
Nicky Leach d36ea13e08
feat(acpx): stage once per remote ACP session - compatible resume reuses staged runtime, no cross-session credential reuse (#10089)
## Thinking Path

> - Paperclip coordinates autonomous agent work across isolated
company-scoped sessions
> - The ACP remote lane stages workspaces and managed home state inside
the sandbox so sessions can resume safely
> - If a compatible resume re-staged everything every time, it would
waste work and risk inconsistent session reuse behavior
> - If an incompatible resume reused the wrong staged runtime, it could
cross session boundaries or leak credentials
> - This pull request keeps the session fingerprint as the scoping key
and adds a staged-runtime cache keyed to that fingerprint
> - Compatible resumes now reuse the already staged runtime while
incompatible fingerprints stage fresh
> - The benefit is faster safe resumes without weakening session
isolation or credential separation

## Linked Issues or Issue Description

### Problem or motivation
The ACP remote lane currently needs to preserve safe resume behavior
without repeatedly re-staging work that is already valid for the same
session. The failure mode to avoid is letting one session reuse another
session's staged workspace or credentials.

### Proposed solution
Keep the session fingerprint as the scoping key and add a staged-runtime
cache keyed to that fingerprint. When the fingerprint matches, reuse the
already staged workspace and managed home. When the fingerprint changes,
stage fresh.

### Alternatives considered
- Always restage on resume: safest mechanically, but wastes work and
breaks the compatible-resume optimization.
- Reuse without fingerprint scoping: too risky because it could cross
session boundaries.

### Roadmap alignment
This is a narrow implementation change for the ACP remote lane and does
not duplicate any broader roadmap item I could find in `ROADMAP.md`.

### Additional context
The change preserves the existing session fingerprint contents and codex
auth copy-back cadence while adding tests for compatible reuse,
incompatible fresh staging, no cross-session credential reuse, and
failed-turn eviction.

## What Changed

- Added a staged-runtime cache in the ACP remote execution path keyed by
the session fingerprint.
- Reused the existing staged workspace and managed home for compatible
resumes.
- Kept incompatible fingerprints on the fresh staging path.
- Preserved the existing session fingerprint contents and codex auth
copy-back cadence.
- Added tests for compatible reuse, incompatible fresh staging, no
cross-session credential reuse, and failed-turn eviction.

## Verification

- `pnpm exec vitest run
packages/adapter-utils/src/acpx-engine/execute.test.ts` (74/74 pass,
including the active-turn lease regression)
- `pnpm exec tsc -p packages/adapter-utils/tsconfig.json --noEmit`
- Verified the PR touches only
`packages/adapter-utils/src/acpx-engine/execute.ts` and
`packages/adapter-utils/src/acpx-engine/execute.test.ts`

## Risks

- A cache eviction bug could cause an unavailable or partially staged
runtime to be reused.
- If the fingerprint scoping regressed, a session could incorrectly
reuse another session's state.
- The change is isolated to the ACP remote lane, but it still affects
resume behavior for that path.

## Model Used

OpenAI Codex, GPT-5, reasoning-capable coding agent, tool-enabled
session.

## 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
- [ ] 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-07-23 10:13:44 -07:00
..
claude-local feat(acpx): per-adapter managed-home seed (x3) + Codex auth copy-back for remote ACP lane (#10073) 2026-07-23 06:42:52 -07:00
codex-local feat(acpx): stage once per remote ACP session - compatible resume reuses staged runtime, no cross-session credential reuse (#10089) 2026-07-23 10:13:44 -07:00
cursor-cloud fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
cursor-local fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
gemini-local feat(acpx): per-adapter managed-home seed (x3) + Codex auth copy-back for remote ACP lane (#10073) 2026-07-23 06:42:52 -07:00
grok-local fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
hermes fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
hermes-gateway build(deps-dev): bump vitest from 4.1.8 to 4.1.10 (#9886) 2026-07-21 12:04:11 -05:00
openclaw-gateway build(deps): bump ws from 8.19.0 to 8.21.1 (#9891) 2026-07-21 12:03:45 -05:00
opencode-local fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
pi-local fix(runtime): scope PAPERCLIP_ env-binding strip to reserved keys (#9974) 2026-07-22 07:01:57 -05:00
AUTHORING.md PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00