paperclip/doc
Nicky Leach fe803bedf1
feat(server): add a configurable cooldown to the terminal workspace reaper (#11642)
## Thinking Path

> - Paperclip is an open source app that manages AI agents for work.
> - The server manages execution workspaces and their worktrees.
> - The terminal workspace reaper removes a workspace when its issue
tree reaches a terminal state.
> - Immediate removal prevents a person from reopening recently
completed work.
> - This pull request adds a configurable cooldown before the reaper
archives the workspace.
> - The cooldown keeps recent work available and keeps immediate cleanup
available with value `0`.

## Linked Issues or Issue Description

Refs: #7790

**Problem**

The reaper archives an execution workspace and deletes its worktree as
soon as the issue tree becomes terminal. A person cannot reopen recent
work without extra effort.

**Expected behavior**

The reaper should keep a recently completed workspace during a
configurable cooldown window. It should archive older work and support
immediate cleanup when the value is `0`.

**Proposed solution**

Read the cooldown from `PAPERCLIP_WORKSPACE_REAPER_COOLDOWN_DAYS`. Use a
seven-day default. Use the latest terminal timestamp in the source issue
tree as the cooldown anchor.

## What Changed

- Add `PAPERCLIP_WORKSPACE_REAPER_COOLDOWN_DAYS` with a seven-day
default.
- Treat `0` as no cooldown and use the default for negative or
non-numeric values.
- Use the latest `completedAt` or `cancelledAt` value in the source
issue tree.
- Use `updatedAt` when a terminal timestamp is null.
- Skip candidates inside the cooldown and report them in
`skippedCooldown`.
- Recheck the cutoff during the guarded archive operation.
- Document the environment variable and add focused tests.

## Verification

- Run `npx vitest run
server/src/__tests__/execution-workspaces-service.test.ts`.
- Confirm that the test run passes 66 tests.
- Confirm that the tests cover a recent tree, an old tree, value `0`,
and a null terminal timestamp.
- Confirm that the changed files pass `tsc --noEmit`.

## Risks

The default changes terminal workspace cleanup from immediate removal to
a seven-day delay. A value of `0` preserves immediate cleanup. The
guarded archive check limits race risk during concurrent lifecycle
changes.

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

## Model Used

OpenAI Codex, GPT-5, tool use and code execution. This model assisted
with the implementation review and PR preparation.

## 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>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-08-18 11:23:27 -07:00
..
assets
…
connections docs(connections): MCP-direct/DCR playbook section + Notion dry-run appendix (#11030) 2026-08-07 10:52:04 -05:00
design fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
experimental feat(server): configure shared workspace concurrency (#10759) 2026-08-03 14:25:05 -05:00
logs
…
plans
…
plugins feat(sandbox): stream session output by capability, drop three operator flags (#11557) 2026-08-17 13:25:30 -07:00
pr/5429
…
screenshots
…
spec
…
AGENT-ARTIFACTS.md
…
AGENTCOMPANIES_SPEC_INVENTORY.md
…
CHANNELS.md feat(cli): add 'paperclipai channels' to show release lanes and the current one (#11210) 2026-08-11 08:47:32 -07:00
CLI.md fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
CLIPHUB.md
…
DATABASE.md fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
DEPLOYMENT-MODES.md fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
DEVELOPING.md feat(server): add a configurable cooldown to the terminal workspace reaper (#11642) 2026-08-18 11:23:27 -07:00
DOCKER.md
…
GOAL.md
…
HERMES_GATEWAY_ONBOARDING.md fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
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
…
MCP-ACCESS-GOVERNANCE.md
…
MCP-DEMO-SCRIPT.md
…
MCP-RUNTIME-OPERATIONS.md
…
OPENCLAW_ONBOARDING.md
…
PRODUCT.md
…
PUBLISHING.md
…
README-draft.md
…
RELEASE-AUTOMATION-SETUP.md feat(release): add human-gated beta channel with stable soak enforcement (#11008) 2026-08-10 16:52:59 -07:00
RELEASE-CHECKLIST.md feat(release): draft stable notes at beta publish, read them from master at promotion (#11567) 2026-08-17 20:47:23 -07:00
RELEASE-NOTES-mcp-access-governance.md
…
RELEASING.md feat(release): draft stable notes at beta publish, read them from master at promotion (#11567) 2026-08-17 20:47:23 -07:00
SECRETS-AWS-PROVIDER.md
…
SPEC-implementation.md fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
SPEC.md
…
TASK-WATCHDOG.md fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
TASKS-mcp.md
…
TASKS.md
…
TELEMETRY_WORKFLOW.md
…
UNTRUSTED-PR-REVIEW.md
…
acp-run-lifecycle.md refactor(acpx-engine): coordinator-owned ACP run lifecycle with a typed resource ledger (#11576) 2026-08-17 22:02:16 -07:00
execution-semantics.md fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
memory-landscape.md
…
observability.md
…