Files
PaperClipAI/server
Jegor1 1afac2fd30 fix(recovery): do not abort startup recovery on one bad blocking pair (#19193)
<!-- 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
> - At startup, the recovery service reconciles the active recovery
actions
> - When a source issue has healthy child issues, recovery adds the
children to the blocked-by list of the source issue
> - If a child already blocks its source issue, this creates a cycle and
`issuesSvc.update` throws an error
> - The error stops the whole sweep, so recovery does not reach any
later issue
> - This pull request catches the error for one source issue, logs a
warning, and goes on with the next action
> - The benefit is that one bad pair of issues no longer stops startup
recovery for all other issues

## Linked Issues or Issue Description

Refs #11853

**What happened?**

During startup recovery, one bad pair of a source issue and a child
blocker created a cycle. The update threw an error. The error stopped
the recovery sweep for all remaining issues.

**What did you expect to happen?**

One bad pair must not stop startup recovery for every issue. The sweep
must skip the bad pair and continue.

## What Changed

- `reconcileActiveRecoveryActions` wraps the `issuesSvc.update` call
that blocks a source issue on its healthy children in a `try`/`catch`.
- On failure, it logs a warning and counts the action as skipped. It
also reports a retry time 5 minutes later, through
`blockerStallRetryAt`, so the recovery worker schedules another pass.
The sweep continues with the next action.
- A new test seeds two source issues with a healthy child each. The
first source issue also blocks its own child, so blocking it on that
child creates a cycle. The test checks that the first action stays
active, is counted as skipped, and sets a retry time. It also checks
that the second source issue becomes blocked and its action resolves.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/startup-recovery-update-failure.test.ts` (embedded
PostgreSQL, 2 tests pass).
- `pnpm --filter @paperclipai/server typecheck` passes.

## Risks

- The `catch` handles any error from `issuesSvc.update`. If the cause is
a real data or permission problem, the action is skipped and the warning
log is the only signal.
- A skipped action stays active. The retry time makes the worker try it
again after 5 minutes. If the cycle still exists, the warning repeats
every 5 minutes.

> 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

- Provider and model: Anthropic Claude Opus 5.5 (model ID
`claude-opus-5-5`)
- Context window: 1M tokens (128K maximum output)
- Capabilities: adaptive thinking, tool use, and code execution, used
through Claude Code

## 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
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-12-05 03:41:22 -08:00
..