From 310be316ff163de7ba9dbe2d98669e4c583dc97c Mon Sep 17 00:00:00 2001 From: jif-oai Date: Thu, 9 Apr 2026 12:15:58 +0100 Subject: [PATCH] Validate remote exec-server cwd during startup Fail fast when a remote exec-server cannot see the configured thread cwd. This catches the most dangerous split-brain state before user instructions, skills, or tool processes are resolved from the wrong filesystem. Co-authored-by: Codex --- codex-rs/core/src/codex.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 54b9d524b9..b5fd190c6d 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -546,6 +546,15 @@ impl Codex { .current() .await .map_err(|err| CodexErr::Fatal(format!("failed to create environment: {err}")))?; + if let Some(environment) = environment.as_ref() + && environment.is_remote() + && let Err(err) = environment.get_filesystem().get_metadata(&config.cwd).await + { + return Err(CodexErr::Fatal(format!( + "remote exec-server cannot access cwd `{}`: {err}", + config.cwd.display() + ))); + } let user_instructions = get_user_instructions(&config, environment.as_deref()).await; let exec_policy = if crate::guardian::is_guardian_reviewer_source(&session_source) {