Repository navigation
fix(board): give a task's run to its assignee, not to whoever pressed Run - #80
Merged
Merged
Conversation
trigger_task_workflow passed the calling token's owner as the actor, and that actor becomes run.user — which is not just a label: SessionService.create_for_workflow_step reads it to pick the agent credential, the runtime and the model. A project's MCP server carries one person's amcp_ token, so every board task an agent triggered ran as, and was billed to, whoever set that server up. Attribution now follows the task the way every other agent-initiated board action already does (InternalTools::BoardMoveTask#resolve_actor and friends): task.assignee, else the previous run's owner, else the caller, skipping any candidate with no active membership in the company since they hold no credential there. Moving a card into an automated column is the main way these runs start, so matching that rule is what makes the same task cost the same account whichever path launched it. Authorization is unchanged — still the caller's, via the same policy the board controller uses. The response now names the account in `runs_as` so the choice is never silent again. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
… Run run.user is not a label — SessionService.create_for_workflow_step reads it to choose the agent credential, the agent runtime and the model, so it decides which account executes a run and which one is billed. Pressing Run on a card someone else is assigned to therefore spent the clicker's credential on their work, and the personal-MCP tool did the same with the token owner's. Ownership now resolves in one place, TaskService#run_owner_for: the task's assignee, falling back to whoever asked, skipping a candidate with no active membership in the company (no credential there) or with the viewer role (the platform refuses to let a viewer launch a session at all). The card's Run button, trigger_task_workflow and a column auto-trigger all inherit it, so the same task costs the same account however it started. requested_by_id goes into the trigger event's data, so attributing the run to the assignee does not lose who asked. Why one place rather than a fix per caller: every session tool resolves its own actor as `task.assignee || workflow_run&.user`, where workflow_run is the run of the session doing the work. A run owned by the wrong account has an agent that moves each unassigned card as that account, firing more runs owned by it, whose agents do the same — one wrong owner walks the board. For the same reason a previous run's owner is never a fallback: on a task already launched under the wrong account, that owner IS the wrong account. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
… run A nil agent credential is not an error anywhere downstream — SessionContextService writes credentials only `if credential.present?` — so handing a run to an assignee who never connected an agent traded a run on the wrong account for one that comes up with nothing to authenticate as and dies with whatever the CLI says about being logged out. can_own_runs? now also requires an AgentCredential in the task's company, falling back to whoever asked. Not covered, and pre-existing: a candidate who holds some credential but not the runtime the step pins still resolves to nil, which would need a second copy of SessionService's runtime cascade to catch here. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
Moving somebody else's card is housekeeping; the work it kicks off is still theirs. Comment only. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
alex-astafyev
pushed a commit
to alex-astafyev/flow
that referenced
this pull request
Aug 19, 2026
* origin/develop: fix(board): give a task's run to its assignee, not to whoever pressed Run (AixleHQ#80) refactor(profile): redesign My Profile into paired identity/agents bands (AixleHQ#78) fix(inertia): address partial reloads by their server-side prop names (AixleHQ#79)
This was referenced Nov 11, 2026
artempartos
added a commit
that referenced
this pull request
Nov 12, 2026
* chore(deps): bump ransack to 6.1.0 and cuprite to 0.20.1 Supersedes #711. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]> * chore(deps): bump @tabler/icons-react to 3.51.0 and react-resizable-panels to 4.21.0 Supersedes #712. react-resizable-panels goes to 4.21.0 rather than the PR's 4.20.0: it clears the three-day age gate, so yarn resolves it anyway. glob 13.0.6 -> 13.0.7 carries the backported AbortSignal fix for GHSA-3g3m-2fjr-6pw4 (dev-only, through license-checker). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]> * chore(deps): bump glob to 13.0.7 in the Bitbucket app 13.0.7 backports the AbortSignal fix for GHSA-3g3m-2fjr-6pw4 to the 13.x line. The advisory still lists <=14.0.1 as vulnerable, so alert #80 stays open until its range is corrected. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]> --------- Signed-off-by: Artem Petrov <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The symptom
Press Run on a board card assigned to someone else and the run starts under you, not under the assignee.
Why it matters
run.useris not a label.SessionService.create_for_workflow_stepreads it to choose:SessionCompany.agent_credentials_for),run_membership(...).default_agent_runtime),run_credentials(...).first.agent_type).So it decides which account executes the work and which one is billed.
And it does not stay contained. Every session tool resolves its own actor as
task.assignee || workflow_run&.user(InternalTools::BoardMoveTask#resolve_actor,BoardAddComment,BoardAttachAsset), whereworkflow_runis the run of the session doing the work. A run owned by the wrong account therefore has an agent that moves every unassigned card as that account → which fires that column's auto-trigger as that account → which starts another run owned by it → whose agent does the same. One wrong owner walks the board.Provenance (not a regression from #77)
actor: current_usersince4c593384, 2026-04-09 — four months before feat(mcp): watch and control agent sessions from the personal MCP #77.git blameontasks_controller.rb:83confirms it.trigger_task_workflowpassed the personal token's owner, so an agent-triggered task ran as whoever configured the project's MCP server. That one is mine.Both are the same underlying mistake — conflating "who is allowed to launch this" with "who owns what gets launched" — so this fixes it once rather than per caller.
The fix
One rule,
TaskService#run_owner_for: the task's assignee, falling back to whoever asked, skipping a candidate whoEvery entry point inherits it: the card's Run button,
trigger_task_workflow, and a column auto-trigger from a card move or a resolved gate. The same task now costs the same account however it started.Two supporting details:
requested_by_idgoes into the trigger event'sdata, so attributing the run to the assignee does not lose who asked.TriggerEventhas only one actor column, and it now means "owner"; the audit answer lives beside it.trigger_task_workflowalso readsruns_asback off the created run instead of predicting it, so there is no second copy of the rule to drift.Behaviour changes to review
requested_by_idtrigger_task_workflow(MCP)The drag/auto-trigger row is the widest one — say the word and I will scope it back to the two explicit triggers.
Not covered
Runs already created under the wrong account keep propagating until they drain, and this change does not repair them. Worth noting: MCP-seeded triggers recorded
source: "manual", identical to a button click, so the blast radius cannot be reconstructed precisely fromtrigger_eventsalone — only by actor and timestamp. Happy to add a provenance marker and/or a repair query if you want the history cleaned.Check suite
docker compose exec -T web make check_all— all green (rails-test, rubocop, brakeman, system-test, eslint, typescript, fe-test, vite-build); backend line coverage 91.46%.New tests: 6 in
task_service_test.rb(assignee wins; unassigned → requester; viewer assignee skipped; revoked assignee skipped;requested_by_idrecorded; card move attributes to the assignee), 1 intasks_controller_test.rb(the button), and the MCP tool's own set including "a previous run's owner is not inherited on a forced retrigger".🤖 Generated with Claude Code