## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - CI runs fixtures for real CLI servers and SSH commands. > - The CLI fixture can lose its fallback port before the server binds it. > - The SSH login-profile fixture must supply the command payload on stdin. > - These fixture failures stop CI before it can verify the application behavior. > - This pull request adds bounded CLI bind retries and supplies the SSH stdin payload. > - The fixtures retain their startup deadlines, child identity checks, and behavior assertions. ## Linked Issues or Issue Description **What happened?** [Source verification 47462717613, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47462717613/job/145492578739) failed in `cli/src/__tests__/company-import-export-e2e.test.ts`. The fixture occupied port 41511. The server selected 41512, then exited with `listen EADDRINUSE: address already in use 127.0.0.1:41512`. The suite failed before health readiness. The other 354 files passed, with 3,971 tests passed and one skipped. This cancelled [image run 47462717565](https://github.com/paperclipai/paperclip/actions/runs/47462717565). The SSH login-profile fixture also ran the command bootstrap without its stdin payload. It exited with code 125 before it could check profile behavior. [CI run 47464397195 on `ef3250d`](https://github.com/paperclipai/paperclip/actions/runs/47464397195/job/145497678930) failed on that test. The CLI shard passed in the same run. **Expected behavior** A fixture can start a fresh attempt after it loses a listener bind race to another local process. A configuration error, signal exit, health timeout, or test assertion must still fail. Runtime discovery must use the child PID and actual fallback port. The SSH fixture must supply `stdinPrefix` to execute the generated remote command. **Steps to reproduce** The failed source was master `dfe392dada69838da3d7c33a0ef00d7e4cfc60f3`, in local trusted mode. Reserve a loopback port, then make a child process bind that port. The new socket regression test does this without timing assumptions. Without the retry policy, the first collision aborts startup. For the SSH failure, run `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run packages/adapter-utils/src/ssh-fixture.test.ts -t 'survives a bash-only login profile' --maxWorkers=1` on a host with `dash`. Before the stdin fix, it exits 125 with empty output. Refs #23813: that separate database teardown fix is already in this master revision. This failure is a listener bind collision. ## What Changed - Retry only a child exit with code 1 and the listener `EADDRINUSE` diagnostic on stderr. Limit startup to three attempts. - Release the old port reservation and start a fresh child with a fresh requested-port reservation on each attempt. - Share the original 90-second startup deadline across attempts. Keep the PID-matched runtime health check and the assertion that the server used a fallback port. - Recognize a child that has already exited by signal, so cleanup does not wait for a past exit event. - Add real-socket regression tests for recovery, failure limits, and other startup errors. - Pass `target.stdinPrefix` to the SSH login-profile fixture process, as required by the existing transport contract. ## Verification - CLI red: with the policy set to one attempt, the socket recovery test failed with the same `EADDRINUSE` diagnostic as CI. The bounded-attempt test also failed. - CLI green: `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run cli/src/__tests__/server-startup.test.ts cli/src/__tests__/company-import-export-e2e.test.ts --maxWorkers=1` passed both suites and all five tests after rebase. CLI typecheck passed. These files have not changed since that verification. - SSH red: the targeted login-profile test failed locally with exit 125 and retries disabled, matching the CI failure on `ef3250d`. - SSH green: `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run packages/adapter-utils/src/ssh-fixture.test.ts --maxWorkers=1` passed 26 tests, with two skipped. `pnpm exec tsc --noEmit -p packages/adapter-utils/tsconfig.json` passed. - The test budget check passed for all three changed test files. `git diff --check` passed. Final head: `4b0a5e4b96702829454b101b57be313b8908a63e`. - The CLI dependency-selection plan retained 2,347 of 3,084 test files on the previous head. Required CI will verify the final head with the SSH correction. No full local suite was run. - [Greptile rated final head `4b0a5e4b96702829454b101b57be313b8908a63e` 5/5](https://github.com/paperclipai/paperclip/pull/23830#issuecomment-7429780977), with no actionable findings or review threads. Final check results: 76 passed, six skipped, none pending or failed. The [final CI workflow](https://github.com/paperclipai/paperclip/actions/runs/47465088910) passed, and GitHub reports no merge conflicts. - Operational recovery: [image run 47463279495](https://github.com/paperclipai/paperclip/actions/runs/47463279495/job/145501215693) passed exact-source verification and published the AMD64/ARM64 manifest for master `6a5dfc028831831756bea006df4e399e31cdf281`. Tag: `ghcr.io/paperclipai/paperclip:sha-6a5dfc0`. Digest: `sha256:44576ab5bc386903dd592ed1f3e7277f60e0cd6c696590996d02330be2fbdbff`. All publication gates remained in place. This establishes publication recovery; these fixture changes address recurrence and still need to merge. ## Risks - Low risk. This changes test fixture startup only. - A persistent collision still fails after three attempts. Other failures retain their diagnostics and do not retry. Each recovered collision emits a warning in the test log. - Production listener selection is unchanged. This PR does not add a production server restart policy. - No documentation change is needed because the application contract does not change. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell tools. The context window size is not exposed. ## 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>
@paperclipai/adapter-utils
Shared utilities for Paperclip adapters: process spawning, environment injection, sandbox/SSH transport, workspace sync, and the round-trip helpers that move code between the local execution-workspace cwd and wherever the agent actually runs.
For the adapter-author guide see
docs/adapters/creating-an-adapter.md
and the in-repo notes at packages/adapters/AUTHORING.md.
Sandbox bridge deadlines
Command-managed bridge control operations (queue reads, input delivery, setup, and cleanup) have a host-enforced deadline of at most 30 seconds per shell command. A shorter configured timeout still applies. These operations cannot inherit the agent run's hours-long lifetime or wait forever on a provider that ignores its timeout. Long-lived agent session commands keep their own limits.
A control timeout reports a transport failure. It does not prove that the remote command stopped and does not replay an uncertain write. The process session closes failed input delivery and uses its existing shutdown path; normal execution settlement must still verify termination.
Native archive transfer deadlines
Native syncIn and syncOut calls accept an optional minimumTimeoutMs budget. The
server validates this budget and extends the worker RPC deadline. Providers can
honor this field for file transfers without changing their configuration. Daytona
uses the larger of this minimum and its configured timeout. Other providers keep
their existing behavior. The minimum is limited to 30 minutes and does not change
sandbox lifetimes, stored settings or the timeout for other commands.
The remote-workspace archive path uses the verified capture size for downloads and the local archive size for uploads. Large archives get one second per MiB plus 60 seconds, capped at 30 minutes. Small archives keep the existing provider timeout when that calculation is no greater than five minutes. Archive size, checksum, confinement and host space checks still apply.
An exact retained-sandbox resume keeps its recorded provider timeout and RPC overhead. It uses the normal one-minute fallback only when no timeout was recorded. A five-minute cold restore must not be cut off by that fallback. Resume still targets the recorded allocation and does not acquire a replacement.
No-remote-git contract
The local execution-workspace cwd is the only persistence boundary across runs. No adapter may depend on a git remote for cross-run state.
Adapters that run the agent on a different host should use the SSH round-trip
helpers in src/ssh.ts:
prepareWorkspaceForSshExecution({ spec, localDir, remoteDir })— bundles the local cwd (tracked files, dirty edits, untracked additions, and the git history needed to reconstruct it) toremoteDirbefore the run starts. Runs with nogit remoteconfigured.restoreWorkspaceFromSshExecution({ spec, localDir, remoteDir, ... })— syncs the remote cwd back intolocalDirafter the run, including any new commits the agent created. Also runs with nogit remoteconfigured.
prepareRemoteManagedRuntime in
src/remote-managed-runtime.ts wraps both
calls for adapters that want a per-run remote workspace and an automatic
restoreWorkspace() finally hook.
The invariant is pinned by the no-remote-git contract case in
src/ssh-fixture.test.ts, which asserts that a
remote-only commit propagates to the local worktree through the
prepare → restore round-trip with no git remote configured at any point. Do
not regress that test.