Files
PaperClipAI/server/src/routes
DottaandClaude Opus 5.5 574448e910 fix(server): apply the issue interaction resolution policy to direct tool review decisions (#22656)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - When an agent's tool call needs review, Paperclip creates a tool
action request and an approval card on the task
> - A person can decide it on the card (the issue thread path) or
through `POST /api/tool-gateway/action-requests/:id/approve|decline`
> - The issue thread path applies the interaction resolution policy, but
the direct routes checked only company membership
> - So the two paths could give different answers for the same review,
for example in another member's private chat
> - This pull request puts the human rule for tool reviews in one shared
function and applies it to every human decision on a pending review
> - The benefit is that the direct routes and the card always agree on
who can decide a tool review

## Linked Issues or Issue Description

Refs #22635

**What happened?**
The direct approve and decline routes for tool action requests skipped
the issue-interaction resolution policy. A member could decide a tool
review that the issue thread path refuses, for example a review in a
chat conversation that another member owns.

**What did you expect to happen?**
Both paths use the same policy and give the same result.

**Steps to reproduce**
Open a chat conversation as one member, let the agent request a reviewed
tool call, then approve it through the direct route as a different
member. The new test covers this case.

**Impact**
Access-control hardening for tool reviews.

## What Changed

- Add `evaluateHumanToolReviewResolution`,
`assertHumanToolReviewResolution` and
`conversationInteractionResponderAllowed` to
`server/src/services/issue-thread-interaction-resolution.ts`. The rule
applies the personal-conversation visibility rule, the conversation
owner rule and the existing audience evaluator
(`evaluateIssueThreadInteractionResolverAudience`, as a governed
action).
- `commitToolActionReview` applies this rule inside its decision
transaction, on the issue and interaction rows it already locks. Both
the issue thread path and the direct routes reach it, so one rule
decides for both.
- The direct approve and decline routes call the same rule function
first, for pending and settled reviews, before any state change or
detail is returned (for example a cancelled request after a signature
failure, expiry, or formal approval details). The in-transaction check
stays the authoritative one.
- A settled request with no task or interaction can be read only by the
person who requested it; others get `404`. Only the explicit internal
recovery flag skips the check.
- A decision with no user identity is refused with
`human_review_required`; the code no longer substitutes a placeholder
identity.
- The issue thread route uses `conversationInteractionResponderAllowed`
for its existing conversation owner check.
- Recovery of an already approved review passes an explicit internal
flag and skips the human check, so interrupted executions still resume
with no user action.

## Verification

- New table test in `server/src/__tests__/tool-gateway.test.ts` mounts
the real issue routes and the gateway routes on one database, for a chat
owned by one member, a personal dashboard conversation and an ordinary
task. For approve and decline it compares both paths for the owner and
another member. It also checks settled reviews through the direct route,
the recovery of an approved review, that a non-owner cannot cancel a
review with an unverifiable signature or see expiry details, that a
decision without a user is refused, and that a detached settled request
is visible only to its requester. Before the fix the direct route let
the other member approve a chat review and the action ran (`200`,
`executed`). After the fix both paths refuse the other member for chats
(`403`) and personal dashboards (`404`), both allow the other member for
ordinary tasks, and both allow the owner.
- `npx vitest run` on `tool-gateway`, `issue-thread-interaction-routes`,
`agent-conversations`, `connection-management.integration`, `mcp-tasks`
and `prompt-injection-gateway`: 497 tests pass.
- `tsc --noEmit` for `server` passes.

## Risks

- A member who is not the owner of a private chat can no longer approve
or decline its tool reviews through the direct routes. The card already
refused this.
- Low risk otherwise. Ordinary task reviews have no addressee and stay
open to non-viewer members, as before.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with
tool use and code execution.

## 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
- [ ] 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:50:38 +00:00
..
…
…
…