Deprecate TurnContext cwd and resolve_path (#22519)

## Why

`TurnContext::cwd` and `TurnContext::resolve_path` are being phased out
in favor of using the selected turn environment cwd directly.
Deprecating both APIs makes any new direct dependency visible while
preserving the existing migration path for current callers.

## What Changed

- Marked `TurnContext::cwd` and `TurnContext::resolve_path` as
deprecated with guidance to use the selected turn environment cwd
instead.
- Added exact `#[allow(deprecated)]` suppressions at each existing
direct usage site, including tests, rather than adding crate-wide
suppression.
- Kept the change behavior-preserving: current cwd reads, writes, and
path resolution continue to use the same values.

## Verification

- `just fmt`
- `cargo check -p codex-core`
- `cargo check -p codex-core --tests`
- `git diff --check`
This commit is contained in:
pakrym-oai
2026-05-13 11:15:25 -07:00
committed by GitHub
parent 610b86fefb
commit 4454e1411b
32 changed files with 183 additions and 45 deletions
+7 -2
View File
@@ -83,6 +83,7 @@ async fn exec_command_with_tty(
) -> Result<ExecCommandToolOutput, UnifiedExecError> {
let manager = &session.services.unified_exec_manager;
let process_id = manager.allocate_process_id().await;
#[allow(deprecated)]
let cwd = workdir
.as_ref()
.map_or_else(|| turn.cwd.clone(), |workdir| turn.cwd.join(workdir));
@@ -501,10 +502,12 @@ async fn reusing_completed_process_returns_unknown_process() -> anyhow::Result<(
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn completed_pipe_commands_preserve_exit_code() -> anyhow::Result<()> {
let (_, turn) = make_session_and_context().await;
#[allow(deprecated)]
let cwd = turn.cwd.clone();
let request = test_exec_request(
&turn,
vec!["bash".to_string(), "-lc".to_string(), "exit 17".to_string()],
turn.cwd.clone(),
cwd,
shell_env(),
);
@@ -598,10 +601,12 @@ async fn remote_exec_server_rejects_inherited_fd_launches() -> anyhow::Result<()
turn.environments.turn_environments[0].environment =
Arc::new(remote_test_env.environment().clone());
#[allow(deprecated)]
let cwd = turn.cwd.clone();
let request = test_exec_request(
&turn,
vec!["bash".to_string(), "-lc".to_string(), "echo ok".to_string()],
turn.cwd.clone(),
cwd,
shell_env(),
);
@@ -175,7 +175,9 @@ async fn failed_initial_end_for_unstored_process_uses_fallback_output() {
process_id: 123,
yield_time_ms: 1000,
max_output_tokens: None,
#[allow(deprecated)]
cwd: turn.cwd.clone(),
#[allow(deprecated)]
sandbox_cwd: turn.cwd.clone(),
environment: turn
.environments
@@ -200,6 +202,7 @@ async fn failed_initial_end_for_unstored_process_uses_fallback_output() {
/*process_started_alive*/ false,
&context,
&request,
#[allow(deprecated)]
turn.cwd.clone(),
transcript,
"PRE_DENIAL_MARKER".to_string(),