From 67b2c8c6fb8b91f9f290b1ee6ec8af74e66006e6 Mon Sep 17 00:00:00 2001 From: chess Date: Thu, 20 Aug 2026 23:10:20 +0000 Subject: [PATCH] Defer legacy filesystem policy projection (#39813) ## Why Applying session settings rebuilt and compared a legacy filesystem policy even when the update could not trigger cwd-based policy rebinding. ## What changed Compute the legacy projection only for cwd changes whose filesystem policy has a rebindable project-root write entry. Preserve the existing equivalence check before rederiving the policy. GitOrigin-RevId: c428a5c54f1b5b1300be406cac374a6fd29bb9a8 --- codex-rs/core/src/session/session.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index c185a62455..8684fc4588 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -361,14 +361,6 @@ impl SessionConfiguration { let current_file_system_sandbox_policy = self.file_system_sandbox_policy(current_environments); let current_network_sandbox_policy = self.network_sandbox_policy(); - let legacy_file_system_projection = - FileSystemSandboxPolicy::from_legacy_sandbox_policy_preserving_deny_entries( - ¤t_sandbox_policy, - self.cwd(), - ¤t_file_system_sandbox_policy, - ); - let file_system_policy_matches_legacy = current_file_system_sandbox_policy - .is_semantically_equivalent_to(&legacy_file_system_projection, self.cwd()); let file_system_policy_has_rebindable_project_root_write = current_file_system_sandbox_policy .entries @@ -503,8 +495,15 @@ impl SessionConfiguration { ), )?; } else if cwd_changed - && file_system_policy_matches_legacy && file_system_policy_has_rebindable_project_root_write + && current_file_system_sandbox_policy.is_semantically_equivalent_to( + &FileSystemSandboxPolicy::from_legacy_sandbox_policy_preserving_deny_entries( + ¤t_sandbox_policy, + self.cwd(), + ¤t_file_system_sandbox_policy, + ), + self.cwd(), + ) { // Preserve richer split policies across cwd-only updates; only // rederive when the session is already using a structurally