Avoid materializing writable-root carveouts for presence checks (#39812)

## What changed

- Add `FileSystemSandboxPolicy::has_writable_roots_with_cwd` to detect an
  effective writable root without constructing its read-only carveouts.
- Use the helper when classifying permission profiles and selecting patch
  rejection reasons.

## Testing

- Verify the presence check matches the existing materialized-root result
  across read-only, unrestricted, external, writable, denied, and unresolved
  special-path policies.

GitOrigin-RevId: 17ee490aa3180e05732133203f68544d9de5268b
This commit is contained in:
chess authored and copyberry committed 2026-08-20 23:26:59 +00:00
1 parent 21facf2273
commit 969efa5470
3 files changed
+54 -9

No files matched your search

+3 -5
View File
@@ -102,11 +102,9 @@ fn patch_rejection_reason(
file_system_sandbox_policy: &FileSystemSandboxPolicy,
cwd: &PathUri,
) -> &'static str {
let has_no_writable_roots = cwd.to_abs_path().is_ok_and(|cwd| {
file_system_sandbox_policy
.get_writable_roots_with_cwd(cwd.as_path())
.is_empty()
});
let has_no_writable_roots = cwd
.to_abs_path()
.is_ok_and(|cwd| !file_system_sandbox_policy.has_writable_roots_with_cwd(cwd.as_path()));
match permission_profile {
PermissionProfile::Managed { .. }
if !file_system_sandbox_policy.has_full_disk_write_access()