fix(issues): tighten scope authz, backfill, and visibility helper

Match isAgentCreatedIssue in the 0511 backfill (include created_by_user_id IS NULL), extract surfaceScopeCondition into issue-visibility.ts, let explicit scope filters override includeAgentCreatedTasks=false, reject scope='chat' on non-conversation issues, and forbid agent actors from setting scope='board' on POST/PATCH.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-11-30 18:11:55 -06:00
1 parent 926c67e569
commit ca94323056
6 files changed
+148 -36

No files matched your search

+2 -2
View File
@@ -106,7 +106,7 @@ POST /api/companies/{companyId}/issues
}
```
`scope` is optional (`board` | `channel` | `agent` | `chat`). When omitted, the server derives `chat` for 1:1 conversations, `board` for manual human issues and explicit chat-to-board handoffs, and `agent` for agent-created or automated issues. Passing a non-`chat` scope on a 1:1 conversation returns `422`.
`scope` is optional (`board` | `channel` | `agent` | `chat`). When omitted, the server derives `chat` for 1:1 conversations, `board` for manual human issues and explicit chat-to-board handoffs, and `agent` for agent-created or automated issues. Passing a non-`chat` scope on a 1:1 conversation or `scope: "chat"` on a non-conversation issue returns `422`. Agent actors cannot pass `scope: "board"` directly (`403`).
## Update Issue
@@ -121,7 +121,7 @@ Headers: X-Paperclip-Run-Id: {runId}
The optional `comment` field adds a comment in the same call. For execution-policy review or approval decisions, the decision comment must be included in this same `PATCH`; a prior `POST /api/issues/{issueId}/comments` does not satisfy the stage decision guard.
Updatable fields: `title`, `description`, `status`, `scope`, `priority`, `assigneeAgentId`, `projectId`, `goalId`, `parentId`, `billingCode`. Existing 1:1 conversation issues must keep `scope: "chat"` (other values return `422`).
Updatable fields: `title`, `description`, `status`, `scope`, `priority`, `assigneeAgentId`, `projectId`, `goalId`, `parentId`, `billingCode`. Existing 1:1 conversation issues must keep `scope: "chat"` and non-conversation issues cannot be set to `scope: "chat"` (`422`). Agent actors cannot promote issues to `scope: "board"` (`403`).
For `PATCH /api/issues/{issueId}`, `assigneeAgentId` may be either the agent UUID or the agent shortname/urlKey within the same company.