mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 07:42:38 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Routines let people repeat work and select an agent for each manual run. > - The person who starts a manual run must be responsible for that run. > - Routine dispatch queues execution before its transaction commits. > - The execution queue cannot yet read the new routine-run record. It can select the routine owner's account instead. > - This pull request carries the selected responsible user into the assignment wake context. > - The agent can then use the manual caller's account through the existing access checks. ## Linked Issues or Issue Description **What happened?** A person used Run now on another person's routine and selected their own agent. The task belonged to the caller, but the execution used the routine owner's identity. Account access then failed. **Expected behavior** The task, routine run, and agent execution must use the person who starts the manual run. The saved routine must keep its owner. **Steps to reproduce** 1. Create a routine as one person. 2. Use Run now as a second person and select that person's agent. 3. Compare the responsible users on the task and the queued execution. **Paperclip version or commit** Reproduced on master at `2d67b060260f` with a real PostgreSQL database and the heartbeat service. **Deployment mode** Reported on a hosted instance. Reproduced in a source checkout. Related ownership changes: #19128 and #19222. The issue search found no duplicate for this transaction visibility failure. ## What Changed - Add an optional responsible user to the assignment wake helper. Other callers keep their current behavior. - Pass the user already selected by routine dispatch into the wake context. Keep the dispatch lock through queue admission. - Add a regression that runs another person's routine with the caller's selected agent through the real heartbeat service. Check both queued and completed execution identity. - Keep the saved routine owner and the existing account access checks. ## Verification - Before the fix, the new regression failed: the execution used the routine owner instead of the caller. - The full heartbeat identity suite passed: 19 tests, including the new regression. The routine service and route suites passed: 130 tests. - The first post-fix run found that the new test caller had no company membership. The fixture now adds an active member, and the full identity suite passes. - Local scope: Node.js 25.9.0 on Linux, PostgreSQL-backed tests, head `93fa698ebae875d7f7357af1d7854b48aef9f824`. - `pnpm verify` selected 2,923 of 3,786 files. Stopped the broad local run under the repository guidance to use focused checks and required CI. Its first 12 tests passed, but the interrupted run is not a pass. Earlier selections were invalidated by the fixture edit. - Greptile: 5/5 on head `93fa698ebae875d7f7357af1d7854b48aef9f824`, with no review threads. Required CI passed at this head: [CI run 44325396087, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/44325396087/attempts/2). All 61 checks are complete: 55 success, 4 skipped, and 2 neutral. Build, typecheck, server tests, Runner tests, and browser tests passed. Two server shards were retried after their runners shut down; both passed. - Worktree preflight installed dependencies and built the shared package and plugin SDK. Its Runner build could not run because Cargo is absent. The focused tests use the source Runner alias. CI supplied build and typecheck coverage; both passed. ## Risks - Low risk. The change carries a server-selected identity through an existing wake context. It adds no database or public API fields. - The optional helper field affects routine dispatch only. Scheduled runs keep the user selected from the saved routine revision. ## Model Used OpenAI Codex, GPT-6, with reasoning, repository tools, 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 - [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>