Use selected turn environments for runtime context (#20281)

## Summary
- make selected turn environments the source of truth for session
runtime cwd and MCP runtime environment selection
- keep local/no-selection fallback behavior intact
- add coverage for duplicate selected environments, cwd resolution, and
MCP runtime environment selection

## Validation
- git diff --check
- rustfmt was run on touched Rust files during the implementation
workflow

CI should provide the full Bazel/test signal.

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-05-01 11:00:14 -07:00
committed by GitHub
Unverified
parent e4d6675632
commit be71b6fcd1
18 changed files with 456 additions and 242 deletions
+9 -3
View File
@@ -96,7 +96,10 @@ async fn exec_command_with_tty(
&request,
tty,
Box::new(NoopSpawnLifecycle),
turn.environment.as_ref().expect("turn environment"),
turn.primary_environment()
.expect("turn environment")
.environment
.as_ref(),
)
.await?,
);
@@ -591,7 +594,7 @@ async fn remote_exec_server_rejects_inherited_fd_launches() -> anyhow::Result<()
let remote_test_env = remote_test_env().await?;
let (_, mut turn) = make_session_and_context().await;
turn.environment = Some(Arc::new(remote_test_env.environment().clone()));
turn.environments[0].environment = Arc::new(remote_test_env.environment().clone());
let request = test_exec_request(
&turn,
@@ -609,7 +612,10 @@ async fn remote_exec_server_rejects_inherited_fd_launches() -> anyhow::Result<()
Box::new(TestSpawnLifecycle {
inherited_fds: vec![42],
}),
turn.environment.as_ref().expect("turn environment"),
turn.primary_environment()
.expect("turn environment")
.environment
.as_ref(),
)
.await
.expect_err("expected inherited fd rejection");