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
This commit is contained in:
chess
2026-08-20 23:10:20 +00:00
committed by copyberry
parent 969efa5470
commit 67b2c8c6fb

View File

@@ -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(
&current_sandbox_policy,
self.cwd(),
&current_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(
&current_sandbox_policy,
self.cwd(),
&current_file_system_sandbox_policy,
),
self.cwd(),
)
{
// Preserve richer split policies across cwd-only updates; only
// rederive when the session is already using a structurally