paperclip/packages/shared/src
Dotta cc81eefb60
Make plan-approval continuations durable after failed wakes (#9331)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents often work from reviewed plans that are approved through
issue-thread interactions.
> - Accepting a plan is not just a UI decision; it must reliably resume
the assignee so approved work continues.
> - A failed continuation wake could leave an approved plan stranded in
review with no durable retry or visible recovery path.
> - This pull request makes approved plan continuations retryable,
recoverable, and visible when resume fails.
> - The benefit is that operators can trust plan approval to either
resume the agent or produce an explicit actionable failure instead of
silent limbo.

## Linked Issues or Issue Description

No public GitHub issue exists. Inline bug report follows the repository
bug template.

### Pre-submission checklist

- [x] I have searched existing open and closed issues and this is not a
duplicate.
- [x] I am on the latest released version of Paperclip or can reproduce
on `master`.
- [x] I have confirmed the error originates in Paperclip itself, not in
my agent adapter, API provider, or local configuration.

### What happened?

When a plan-confirmation interaction was accepted, the assignee
continuation wake could fail before useful agent execution. In that case
the issue could remain in review even though the plan had been approved,
because the failed wake was fire-and-forget and there was no durable
retry or recovery path for accepted continuations.

### Expected behavior

Accepted plan continuations should either wake the assignee
successfully, retry bounded infrastructure failures, recover dropped
wakes, or surface an explicit failure state that operators can act on.

### Steps to reproduce

1. Create an issue with an assignee and a plan confirmation that wakes
the assignee on accept.
2. Accept the confirmation.
3. Simulate a pre-flight continuation failure, such as process loss
before agent start or workspace validation failure.
4. Observe that the approved issue can remain in review without an
active assignee wake or visible retry/failure state.

### Paperclip version or commit

Reproducible on `master` before this PR's retry/recovery changes.

### Deployment mode

Local dev (`pnpm dev`) and server-side recovery paths.

### Installation method

Built from source (`pnpm install`, `pnpm dev`, test runner).

### Agent adapter(s) involved

Not adapter-specific; this is a core continuation/recovery bug. The
tests cover local-agent failure shapes without relying on a
provider-specific API.

### Database mode

Embedded Postgres test database for verification. The affected logic is
database-backed and applies to normal Postgres deployments as well.

### Access context

Board accepts the interaction; agent execution resumes through the
assignee wake path.

### Relevant logs or output

No sensitive logs are needed. The regression tests simulate the failed
wake and recovery states directly.

### Relevant config

No special config is required beyond an assignee with wake-on-demand
enabled.

### Additional context

This PR also prevents a stale workspace-validation payload from
quarantining another issue's active workspace and prevents unrelated
successful runs from masking a continuation that never resumed.

### Privacy checklist

- [x] I have reviewed all pasted output for PII, usernames, file paths,
API keys, tokens, and company names, and redacted where necessary.

## What Changed

- Added bounded infrastructure retries for failed accepted-interaction
continuation wakes.
- Extended stranded issue recovery so dropped accepted-plan continuation
wakes are requeued.
- Recorded and rendered explicit resume-failure state on accepted
confirmation cards.
- Added clean-workspace fallback for workspace-validation failures while
preventing cross-issue workspace quarantine.
- Tightened recovery so unrelated successful runs do not mask an
accepted continuation that never resumed.
- Added focused server/UI coverage for retry scheduling, recovery,
visible failure state, and interaction card rendering.

## Verification

- `pnpm vitest run
server/src/__tests__/heartbeat-retry-scheduling.test.ts
server/src/__tests__/heartbeat-process-recovery.test.ts` — 106 tests
passed.
- Earlier branch verification also covered the issue-thread interaction
card tests for the visible resume-failure UI.
- GitHub CI is green on the replacement PR head, and Greptile reports
5/5 with no blocking issues.

## Risks

- Medium behavioral risk: this changes recovery behavior for accepted
continuation interactions and workspace-validation retries.
- Mitigation: retries are bounded, scoped to same-company issue context,
and workspace quarantine now requires ownership by the issue being
retried.
- Existing stored confirmation results remain compatible because the new
resume-failure field is optional.

> 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 Codex, GPT-5 coding agent, tool-enabled terminal workflow. The
runtime does not expose an exact context-window value to the agent.

## 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-07-10 08:12:16 -05:00
..
telemetry feat(telemetry): document credential health retention (#9248) 2026-07-08 21:27:39 -07:00
types Make plan-approval continuations durable after failed wakes (#9331) 2026-07-10 08:12:16 -05:00
validators Make plan-approval continuations durable after failed wakes (#9331) 2026-07-10 08:12:16 -05:00
adapter-agnostic-keys.test.ts fix: deduplicate adapter-agnostic config keys (#9058) 2026-07-05 21:47:38 -07:00
adapter-type.ts feat(adapters): external adapter plugin system with dynamic UI parser 2026-04-03 21:11:20 +01:00
adapter-types.test.ts [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
agent-eligibility.test.ts [codex] prevent invalid agents from receiving assignments and runs (#7663) 2026-06-06 12:45:57 -05:00
agent-eligibility.ts [codex] prevent invalid agents from receiving assignments and runs (#7663) 2026-06-06 12:45:57 -05:00
agent-url-key.ts
…
api.ts Harden environment deletion and expose delete blast radius (#9250) 2026-07-08 22:04:22 -07:00
config-schema.test.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
config-schema.ts Introduce bind presets for deployment setup 2026-04-11 07:09:07 -05:00
constants.ts Enable sandbox environments for Grok local adapter (#9338) 2026-07-09 20:46:46 -07:00
document-anchors.test.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-anchors.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
environment-custom-images.test.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-custom-images.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-support.test.ts Enable sandbox environments for Grok local adapter (#9338) 2026-07-09 20:46:46 -07:00
environment-support.ts Enable sandbox environments for Grok local adapter (#9338) 2026-07-09 20:46:46 -07:00
execution-workspace-guards.ts Guard closed isolated workspaces on issues 2026-04-04 17:48:54 -05:00
external-objects-server.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.test.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
frontmatter.test.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
frontmatter.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
gitignore-runtime.test.ts chore: ignore materialized Paperclip runtime directory 2026-07-08 17:59:43 -07:00
home-paths.test.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
home-paths.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
index.ts Make plan-approval continuations durable after failed wakes (#9331) 2026-07-10 08:12:16 -05:00
issue-attribution.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-attribution.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-references.test.ts Fix Cloud tenant issue identifier routes (#5196) 2026-05-04 13:20:58 -05:00
issue-references.ts Fix Cloud tenant issue identifier routes (#5196) 2026-05-04 13:20:58 -05:00
issue-thread-interactions.test.ts Expire ask-user questions superseded by comments (#8799) 2026-07-01 09:28:43 -07:00
network-bind.ts Introduce bind presets for deployment setup 2026-04-11 07:09:07 -05:00
pipeline-case-type.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
pipeline-health.test.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
pipeline-health.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
project-mentions.test.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
project-mentions.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
project-url-key.ts fix: append short UUID suffix to project slugs when non-ASCII characters are stripped to prevent slug collisions 2026-03-31 16:35:30 +00:00
resource-memberships.test.ts [codex] Add starred resource sidebar controls (#9085) 2026-07-06 14:09:11 -05:00
responsible-user-denial.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
responsible-user-denial.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
routine-variables.test.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
routine-variables.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
trust-policy.ts Add low-trust review containment (#7530) 2026-06-05 16:48:02 -05:00
work-product.test.ts Add workspace file viewer and artifact links (#7681) 2026-06-09 17:17:43 -05:00
workspace-commands.test.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00
workspace-commands.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00