Files
PaperClipAI/server
323be7e2d3 fix(issues): only treat a pending interaction as a covered blocker path when its host can be woken (#21982)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Blocker attention (`listIssueBlockerAttentionMap` in
`server/src/services/issues.ts`) is the "does this blocked card need a
human" signal: for every blocking edge it decides `covered` (something
will resume it on its own) or `needs_attention`
> - One of its coverage sources is `explicitWaitingIssueIds`, built from
any issue with a *pending* `issue_thread_interactions` row — the
assumption being that accepting the interaction will wake the issue's
assignee and move things forward
> - That assumption is never checked. The only place that turns an
accepted interaction into an actual wakeup,
`queueResolvedInteractionContinuationWakeup`
(`server/src/routes/issues.ts`), silently returns early when the host
issue has no `assigneeAgentId`, is already `done`/`cancelled`, or has a
`continuationPolicy` that cannot queue a wakeup (`request_confirmation`
defaults to `"none"`) — so a pending interaction in any of those shapes
is still counted as a live waiting path even though accepting it wakes
nobody
> - This is not a corner case: an issue can be assignee-less by design
(a standing gate/anchor issue with no owner), and `request_confirmation`
interactions default to a continuation policy that never wakes anyone
unless the caller opts in. Every such blocker reads as `covered`
forever, so no human is ever prompted to look at it
> - This pull request makes the interaction-derived half of
`explicitWaitingIssueIds` mirror the same guard: a pending interaction
only counts as a covered waiting path when its host issue currently has
an assignee agent, is not `done`/`cancelled`, and carries a
`continuationPolicy` of `wake_assignee` or `wake_assignee_on_accept`
> - The benefit is that `blockerAttention` stops reporting a
permanently-unreachable pending interaction as a resolved path, so the
board's "needs a human" signal is accurate for this shape of card; every
other interaction-covered case (an assigned, open host issue with a
wake-capable policy) keeps its current `covered` result

## Linked Issues or Issue Description

No public GitHub issue exists for this; describing it here as a bug
report.

**What happened?**
`listIssueBlockerAttentionMap` classified a blocked issue's blocker as
`covered` solely because the blocker had a `pending` row in
`issue_thread_interactions`, even when the blocker issue had no
`assigneeAgentId`, was already `done`/`cancelled`, or the interaction's
own `continuationPolicy` could never queue a wakeup. Accepting that
interaction can never wake anyone in those shapes:
`queueResolvedInteractionContinuationWakeup` in
`server/src/routes/issues.ts` returns early exactly when the host has no
assignee or is closed, and separately a `request_confirmation`
interaction defaults to `continuationPolicy: "none"` (see
`createIssueThreadInteractionSchema`), which the resolver also never
wakes.

**Expected behavior**
A pending interaction should only be treated as a live waiting path when
accepting it could actually reach an agent — i.e. the host issue has an
assignee agent, is not closed, and the interaction's continuation policy
is wake-capable (`wake_assignee` or `wake_assignee_on_accept`).
Otherwise the blocker should classify as `needs_attention`, the same as
any other dead-end path, so a human is prompted to look at it.

**Steps to reproduce**
1. Create a `blocked` parent issue and a blocker issue with
`assigneeAgentId = null` and `status = "todo"`.
2. Create a `pending` `issue_thread_interactions` row (any kind,
`continuationPolicy: "wake_assignee"`) on the blocker issue.
3. Call `listIssueBlockerAttentionMap` (e.g. via `GET` the issues list
with `status=blocked`) for the parent.
4. Observe `blockerAttention.state === "covered"` even though nothing
will ever wake the blocker.
5. Separately: create an assigned, open blocker with a
`request_confirmation` interaction left at its default
`continuationPolicy: "none"` — same false `covered` result.

**Paperclip version**
`master` at the base commit of this PR (see below).

**Deployment mode**
Self-hosted / any deployment — this is a pure server-side classification
bug, not deployment-specific.

## What Changed

- `server/src/services/issues.ts`: inside
`listIssueBlockerAttentionMap`, only add an interaction's host issue id
to `explicitWaitingIssueIds` when that host currently has a non-null
`assigneeAgentId`, a status other than `done`/`cancelled`, and a
`continuationPolicy` of `wake_assignee` or `wake_assignee_on_accept` —
mirroring the guard in `queueResolvedInteractionContinuationWakeup`
(`server/src/routes/issues.ts`) plus the `request_confirmation`
default-policy gap. Approval-, recovery-, and monitor-derived coverage
in the same function are unchanged; this touches only the
`issue_thread_interactions` branch.
- `server/src/__tests__/issue-blocker-attention.test.ts`: added a
`pendingInteraction` fixture helper and cases covering a pending
interaction on an assignee-less/open blocker, on a closed blocker, and
on an assigned/open blocker left at the default `"none"` continuation
policy — all now classify as `needs_attention`/`attention_required`
(previously `covered`/`active_dependency`) — plus a regression guard
that a wake-capable, assigned, open blocker still classifies as
`covered`/`active_dependency`.

## Verification

Ran on this branch (`server/`, local vitest against an embedded Postgres
instance):

```
npx vitest run src/__tests__/issue-blocker-attention.test.ts
# 33 passed (33)
```

`pnpm --filter @paperclipai/server typecheck` passes with no new errors
in either touched file.

This PR was rebased from an earlier attempt (commits originally authored
2026-09-14/15) onto current `master` after a long gap; both commits
applied with only line-offset conflicts (no logic divergence — verified
the touched types/fields,
`IssueBlockerAttentionNode.{assigneeAgentId,status}` and
`issueThreadInteractions.continuationPolicy`, and the
`ISSUE_THREAD_INTERACTION_CONTINUATION_POLICIES` enum, are all unchanged
on current `master`), then re-tested and re-typechecked against the
current tree.

## Risks

Low risk. The change narrows an existing `covered` classification to a
strictly smaller set of cases (a pending interaction now only counts as
a waiting path when its host is assignable, open, and wake-capable); it
cannot newly mark anything as `covered` that wasn't before. The affected
code path is read-only diagnostics (`blockerAttention` on the issues
list/board), so this cannot change any issue's actual status,
assignment, or interaction state — only how a blocker is reported.
Approval-, recovery-, and monitor-derived coverage are untouched.

**Overlapping open PRs — disclosed, not silently duplicated.**
- [#10398](https://github.com/paperclipai/paperclip/pull/10398) (same
author) also touches `listIssueBlockerAttentionMap`'s
`explicitWaitCandidateIds`/`explicitWaitingIssueIds` block, adding
monitor-based coverage and excluding `cancelled` nodes from the
candidate list. Its diff ends exactly where this PR's change begins
(right after the `interactionRows` query) and does not touch the
`interactionRows` loop body itself — adjacent but non-overlapping.
- [#20807](https://github.com/paperclipai/paperclip/pull/20807) also
touches `server/src/services/issues.ts` and
`server/src/__tests__/issue-blocker-attention.test.ts`, inside the same
function (`readIssueBlockerAttentionBatch`), adding agent-liveness-aware
wake coverage before and after the `interactionRows` loop. It does not
modify the `interactionRows` query or loop body this PR changes. Checked
both diffs line-range by line-range to confirm no overlap.

## Model Used

Claude Sonnet 5 (`claude-sonnet-5`), Anthropic. Standard (non-extended)
thinking mode. Tool use (file read/edit, local vitest/tsc execution,
GitHub CLI) via 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 — no
user-facing docs describe this internal classification helper
- [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: AURDVIN Dev Agent <dev@aurdvin.ch>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-12-05 04:20:13 -08:00
..