paperclip/doc
Dotta ba396c608c
feat(server): configure shared workspace concurrency (#10759)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The heartbeat service starts agent runs in local, SSH, sandbox,
plugin, or Kubernetes environments.
> - Runs can share one project working tree.
> - PR #10699 made every shared working tree single-file, including
trusted local and SSH hosts that support coordinated concurrent work.
> - Operators need a policy that keeps remote environments safe and
restores local multi-agent work.
> - This pull request adds an `auto`, `serialize`, or `allow`
concurrency policy and applies it to the final execution environment.
> - The benefit is safe serialization by default for sandboxed targets
and useful concurrency by default for persistent local targets.

## Linked Issues or Issue Description

Related work: #10699 introduced the busy gate that this change makes
configurable. #7852 covers a separate environment-lease race and does
not provide this dispatch policy.

**Subsystem affected**

`server/` heartbeat orchestration and `packages/shared/` workspace
policy contracts.

**Problem or motivation**

The shared-workspace busy gate always defers a second run. This behavior
prevents local multi-agent projects from running concurrently even when
operators expect agents to coordinate through commits.

**Proposed solution**

Add `sharedWorkspaceConcurrency` with `auto`, `serialize`, and `allow`
values. Default `auto` permits local and SSH concurrency. It serializes
sandbox, plugin, and forced Kubernetes execution.

**Alternatives considered**

Keeping unconditional serialization is too restrictive for persistent
host working trees. Always allowing overlap removes the protection that
sandboxed and remote targets need.

**Roadmap alignment**

This is a focused correction to the shipped cloud and sandbox execution
milestone. It does not add a new roadmap feature.

## What Changed

- Added the optional tri-state field to project policy and issue
override contracts and validators.
- Added a pure resolver with issue override, project policy, and `auto`
default precedence.
- Moved final environment and Kubernetes resolution before the
shared-workspace busy gate.
- Kept the existing deferral and retry behavior for every path that
resolves to serialization.
- Added a task-context warning and a structured log when a run
dispatches beside a live holder.
- Added policy and heartbeat coverage for all requested policy and
environment combinations.
- Documented the new policy and its default behavior.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/execution-workspace-policy.test.ts
src/__tests__/heartbeat-workspace-busy.test.ts` — 32 tests passed.
- `pnpm -r typecheck` — passed.
- `PAPERCLIP_IN_WORKTREE=false
PAPERCLIP_DATABASE_RESTORE_IN_PROGRESS=false
PAPERCLIP_RESTORE_IN_PROGRESS=false pnpm test:run` — all 3,528 server
tests passed. The later UI/workspace phase passed 3,384 tests and hit
one unrelated `CompanyEnvironments` navigation timing failure.
- `pnpm --filter @paperclipai/ui exec vitest run
src/pages/CompanyEnvironments.test.tsx -t "opens the edit form on a
standalone page with existing values and closes after save"` — the
unrelated UI test passed in isolation.
- `pnpm build` — passed.

Policy matrix:

| Policy | Final target | Expected result | Result |
| --- | --- | --- | --- |
| `auto` | local | Dispatch with holder note | Passed |
| `auto` | sandbox | Defer with `workspace_busy` | Passed |
| `auto` | instance-forced Kubernetes | Defer with `workspace_busy` |
Passed |
| `serialize` | local | Defer with `workspace_busy` | Passed |
| `allow` | sandbox | Dispatch with holder note | Passed |

Existing serialization, retry, and stale-holder tests also pass.

## Risks

- `auto` changes the post-#10699 local and SSH behavior back to
concurrent dispatch. Concurrent agents can mutate the same working tree,
so each dispatched run receives an explicit coordination warning.
- `allow` is an operator override and can permit overlap in sandbox or
plugin environments.
- Unknown environment drivers serialize in `auto` mode. This keeps the
fallback conservative.
- There is no database migration. An absent field resolves to `auto`.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI GPT-5 (Codex). The exact API snapshot and context-window size are
not exposed to the agent. Reasoning, repository editing, terminal tool
use, and local code execution were enabled.

## 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-08-03 14:25:05 -05:00
..
assets docs: refresh README roadmap and four pillars (#9922) 2026-07-20 18:00:12 -05:00
connections docs(connections): cross-reference the identity model (identity vs. connections) (#9953) 2026-07-27 19:12:57 -05:00
design design(decisions): flatten decision cards to two task-borrowed types (#10474) 2026-07-31 18:43:40 -07:00
experimental feat(server): configure shared workspace concurrency (#10759) 2026-08-03 14:25:05 -05:00
logs
plans feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
plugins feat(plugin-sdk): human-attributed issue comments for chat gateway plugins (#10050) 2026-07-22 15:54:46 -07:00
pr/5429
screenshots feat(mcp) [split 7/8]: activate Apps and gateway UI (#9562) 2026-07-14 15:40:08 -05:00
spec feat(adapters): confine local coding processes (#9504) 2026-07-14 11:01:19 -05:00
AGENT-ARTIFACTS.md
AGENTCOMPANIES_SPEC_INVENTORY.md
CLI.md feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
CLIPHUB.md
DATABASE.md feat(decisions): add desk workflow and retention (#10672) 2026-08-02 10:47:03 -05:00
DEPLOYMENT-MODES.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
DEVELOPING.md feat(dev): add pnpm dev:mobile and dev:both for prebuilt UI preview (#10718) 2026-08-02 20:26:03 -07:00
DOCKER.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
GOAL.md
HERMES_GATEWAY_ONBOARDING.md
HERMES_GATEWAY_SMOKE.md
INSTALLING.md feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
LOW-TRUST-PRESETS.md docs(execution-semantics): define routable blocking and watchdog restoration (#10094) 2026-07-27 19:10:28 -05:00
MCP-ACCESS-GOVERNANCE.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
MCP-DEMO-SCRIPT.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
MCP-RUNTIME-OPERATIONS.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
OPENCLAW_ONBOARDING.md
PRODUCT.md feat(skills): open-by-default company skill policy and core UX (#9564) 2026-07-15 11:42:40 -05:00
PUBLISHING.md Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
README-draft.md
RELEASE-AUTOMATION-SETUP.md feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
RELEASE-NOTES-mcp-access-governance.md feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
RELEASING.md feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
SECRETS-AWS-PROVIDER.md feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
SPEC-implementation.md feat(decisions): add desk workflow and retention (#10672) 2026-08-02 10:47:03 -05:00
SPEC.md
TASK-WATCHDOG.md
TASKS-mcp.md
TASKS.md
TELEMETRY_WORKFLOW.md Add telemetry proposal extractor (#9544) 2026-07-13 23:47:27 -07:00
UNTRUSTED-PR-REVIEW.md
execution-semantics.md fix(recovery): preserve hand-back wake liveness (#10562) 2026-07-31 11:03:30 -07:00
memory-landscape.md
observability.md feat(server): opt-in OpenTelemetry auto-instrumentation (#3735) 2026-06-12 10:44:22 -07:00