Skip to content

fix(copilot): hold callerless runs to the read grant for server tool writes - #10061

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/copilot-write-cap
Nov 14, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/copilot-write-cap

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • An unattributed inbox message runs as the workspace owner. The CLI lane already holds such a callerless run (secretActorUserId === null) to the api:read grant, but server tools dispatched directly by the agent did not, so settings, dashboards, tests, changelog, workspaces and search_sources write actions authorized the owner's live role (e.g. settings inviting an admin member or revoking API keys)
  • The server-tool adapter now runs a callerless run's calls under the same api:read grant, so the router's existing write-scope check refuses any call whose writes(args) is true, on both the streaming and in-band lanes. Keyed on secretActorUserId rather than userPermission, because userPermission never reaches Go's in-band lane
  • changelog declares writes() (its operations already declare api:write; this keeps the router's pre-dispatch check complete)
  • The executor no longer replaces a workspace run's permission with its target's live role when the run names its own workspace as target; only organization chats take the target's role
  • Attributed runs, read-only members and organization chats are unchanged

Type of Change

  • Bug fix

Testing

  • New project-file-read.integration.ts case (real Postgres): a callerless settings update through the server-tool handler is refused with the scope error and the row is unchanged, reads still work, the attributed write lands. Red on the pre-fix adapter (the write went through), green after; whole file passes (18 tests)
  • New executor test: a capped workspace run naming its own workspace keeps its cap; red on the pre-fix code
  • bunx vitest run lib/mothership/tools lib/mothership/tool-executor lib/mothership/agent-cli (1,003 tests), biome; type-check and check:audits in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant