Scope createAgentTask to the window's team (REV-2331) - #15564
Open
warp-agent-staging[bot] wants to merge 1 commit into
Open
Scope createAgentTask to the window's team (REV-2331)#15564warp-agent-staging[bot] wants to merge 1 commit into
warp-agent-staging[bot] wants to merge 1 commit into
Conversation
Contributor
Author
|
This PR was generated with Warp. Comment |
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.



Summary
Scopes
createAgentTaskto the window's team by sendingX-Warp-Team-Uid, using the transport landed in #15557 (REV-2331). Without the header, the server falls throughGetActiveTeamOrFallbackToPrincipalto the lowest-id team when deciding a locally-created task's owner (team vs. personal, for billing/visibility purposes).Of the operations in this group —
createAgentTask,updateAgentTask, the runner CRUD (getRunners,upsertRunner,deleteRunner), andupsertCloudEnvironment— onlycreateAgentTaskturned out to need (and be able to receive) a header. Each other operation is addressed below with why it was left unscoped.Changes
AIClient::create_agent_tasknow takesteam_scope: Option<RequestTeamScope>and sends it via a newServerApi::send_team_scoped_graphql_requesthelper (mirrorssend_graphql_request, using the transport'sgraphql_request_options_with_team).terminal_pane.rs::launch_local_no_harness_child→child_agent_launch::prepare_local_oz_child_launch, viaViewContext<PaneGroup>.terminal_pane.rs::launch_local_harness_child→local_harness_launch::prepare_local_harness_child_launch, same source.RequestTeamScope::from_scope(&UserWorkspaces::as_ref(ctx).team_context_for_view(ctx)), the established pattern from Scope /ai/transcribe to the window's team #15554.create_agent_task'steam_scopeparameter isOptionrather than mandatory.Left unscoped, with reasons
create_agent_taskfromwarp agent run(app/src/ai/agent_sdk/mod.rs::initialize_new_task): this is the headless CLI path (AgentDriverRunner::setup_and_run_driver, driven byRunAgentArgs). There is no window, andRunAgentArgs— unlikeRunCloudArgs, which hasObjectScope/--team— has no team flag to resolve one from. PassingNonepreserves today's behavior.create_agent_taskfrom the TUI (crates/warp_tui/src/orchestration_model.rs::begin_local_oz_child_launch): the TUI does have its own window/team-per-window concept (seeteam_menu.rs), but the constructors that turn aWindowIdinto aTeamContext/RequestTeamScope(UserWorkspaces::team_context_for_viewand friends) arepub(crate)to theappcrate and not exposed across the crate boundary towarp_tui. Exposing one felt like a bigger call than this PR should make unilaterally, so I left itNoneand flagged it here rather than adding a new public constructor.update_agent_task: server-side (logic/ai/ambient_agents/update_agent_task.go), this resolver never callsGetActiveTeamOrFallbackToPrincipal— authorization is entirely by workload token / task ownership, not active team. Sending the header would be a no-op. Its only call sites are inside the headlessAgentDriverbackground process anyway (noViewContextreachable there, regardless of how the task was launched), so there's no live scope to send even if the server did consume it.get_runners: server-sidelogic.GetRunnersreturns everything the principal can see across every team plus personal (viaGetAccessibleGenericStringObjectsByFormat), with no per-team filter. Scoping it would be a no-op.delete_runner: authorized entirely off the resolved runner object (ResolveRunnerConfig+AgentPlatformRunnersDeleteAction); no team parameter enters the resolver at all.upsert_runner(create path,oz runner create): already names its team explicitly viainput.owner(resolved from--team/--personal/sole-team incommon::resolve_owner), so per the "already names a team" rule this must keep sending no header — and does.upsert_runner(update path,oz runner update):owneris intentionallyNoneon update (an update shouldn't reassign ownership), and the server does fall throughGetActiveTeamOrFallbackToPrincipalfor the resultingteamvalue, which factory-uid and registry-credential-owner validation then use. This is a real instance of the bug. ButRunnerCommandRunner::update_runneris a headless CLI path (oz runner update) with no window, andUpdateRunnerArgshas no--teamflag to resolve one from. I could derive the runner's own current owner from theget_runners()lookup already performed here (existing.scope.uid), but that would require a second construction path outsideRequestTeamScope/TeamScope, which the brief for this migration explicitly rules out. Flagging this rather than building new CLI/infra scope plumbing unprompted.upsert_cloud_environment: not called by this client at all (no Rust codegen or call site references it) — nothing to scope.Verification
./script/formatcargo clippy -p warp --lib --tests -- -D warnings— cleancargo check -p warp --lib --tests— clean./script/bundle --channel oss --nouniversal --check-only— clean (only pre-existing, unrelated warnings inwarp_terminal)cargo nextest run -p warp -E 'test(local_harness_launch) or test(child_agent_launch) or test(terminal_pane)'— 27 tests passedcrates/warp_tuiin this sandbox:cargo check -p warp_tui --lib --testsfails on unmodifiedmastertoo, with a pre-existing, unrelatedE0046 missing get_cursor_shapeerror incrates/warpui. My one-line change there (passingNoneplus a comment) is a minimal, mechanical addition to an existing call site.