@@ -2631,9 +2631,8 @@ impl Config {
26312631 Some ( WindowsSandboxModeToml :: Unelevated ) => WindowsSandboxLevel :: RestrictedToken ,
26322632 None => WindowsSandboxLevel :: from_features ( & features) ,
26332633 } ;
2634+ let memories_config: MemoriesConfig = cfg. memories . clone ( ) . unwrap_or_default ( ) . into ( ) ;
26342635 let memories_root = memory_root ( & codex_home) ;
2635- std:: fs:: create_dir_all ( & memories_root) ?;
2636- let internal_writable_roots = vec ! [ memories_root] ;
26372636
26382637 let profiles_are_active = effective_permission_selection. profiles_are_active (
26392638 default_permissions_override. as_deref ( ) ,
@@ -2701,8 +2700,8 @@ impl Config {
27012700 file_system_sandbox_policy,
27022701 mut active_permission_profile,
27032702 mut profile_workspace_roots,
2704- ) = if let Some ( mut permission_profile) = permission_profile {
2705- let ( mut file_system_sandbox_policy, network_sandbox_policy ) =
2703+ ) = if let Some ( permission_profile) = permission_profile {
2704+ let ( file_system_sandbox_policy, _network_sandbox_policy ) =
27062705 permission_profile. to_runtime_permissions ( ) ;
27072706 let configured_network_proxy_config =
27082707 if profile_allows_configured_network_proxy ( & permission_profile)
@@ -2726,30 +2725,6 @@ impl Config {
27262725 } else {
27272726 NetworkProxyConfig :: default ( )
27282727 } ;
2729- let materialized_file_system_sandbox_policy = file_system_sandbox_policy
2730- . clone ( )
2731- . materialize_project_roots_with_workspace_roots ( & workspace_roots) ;
2732- let materialized_permission_profile =
2733- PermissionProfile :: from_runtime_permissions_with_enforcement (
2734- permission_profile. enforcement ( ) ,
2735- & materialized_file_system_sandbox_policy,
2736- network_sandbox_policy,
2737- ) ;
2738- let sandbox_policy = compatibility_sandbox_policy_for_permission_profile (
2739- & materialized_permission_profile,
2740- & materialized_file_system_sandbox_policy,
2741- network_sandbox_policy,
2742- resolved_cwd. as_path ( ) ,
2743- ) ;
2744- if matches ! ( sandbox_policy, SandboxPolicy :: WorkspaceWrite { .. } ) {
2745- file_system_sandbox_policy = file_system_sandbox_policy
2746- . with_additional_legacy_workspace_writable_roots ( & internal_writable_roots) ;
2747- permission_profile = PermissionProfile :: from_runtime_permissions_with_enforcement (
2748- permission_profile. enforcement ( ) ,
2749- & file_system_sandbox_policy,
2750- network_sandbox_policy,
2751- ) ;
2752- }
27532728 (
27542729 configured_network_proxy_config,
27552730 permission_profile,
@@ -2794,7 +2769,7 @@ impl Config {
27942769 dedupe_absolute_paths ( & mut configured_workspace_roots) ;
27952770 file_system_sandbox_policy = file_system_sandbox_policy
27962771 . with_materialized_project_roots_for_workspace_roots ( & configured_workspace_roots) ;
2797- let mut permission_profile = if let Some ( permission_profile) =
2772+ let permission_profile = if let Some ( permission_profile) =
27982773 builtin_permission_profile ( default_permissions, builtin_workspace_write_settings)
27992774 {
28002775 permission_profile
@@ -2804,30 +2779,6 @@ impl Config {
28042779 network_sandbox_policy,
28052780 )
28062781 } ;
2807- let materialized_file_system_sandbox_policy = file_system_sandbox_policy
2808- . clone ( )
2809- . materialize_project_roots_with_workspace_roots ( & workspace_roots) ;
2810- let materialized_permission_profile =
2811- PermissionProfile :: from_runtime_permissions_with_enforcement (
2812- permission_profile. enforcement ( ) ,
2813- & materialized_file_system_sandbox_policy,
2814- network_sandbox_policy,
2815- ) ;
2816- let sandbox_policy = compatibility_sandbox_policy_for_permission_profile (
2817- & materialized_permission_profile,
2818- & materialized_file_system_sandbox_policy,
2819- network_sandbox_policy,
2820- resolved_cwd. as_path ( ) ,
2821- ) ;
2822- if matches ! ( sandbox_policy, SandboxPolicy :: WorkspaceWrite { .. } ) {
2823- file_system_sandbox_policy = file_system_sandbox_policy
2824- . with_additional_legacy_workspace_writable_roots ( & internal_writable_roots) ;
2825- permission_profile = PermissionProfile :: from_runtime_permissions_with_enforcement (
2826- permission_profile. enforcement ( ) ,
2827- & file_system_sandbox_policy,
2828- network_sandbox_policy,
2829- ) ;
2830- }
28312782 let active_permission_profile = if using_implicit_builtin_profile
28322783 && default_permissions == BUILT_IN_WORKSPACE_PROFILE
28332784 && cfg. sandbox_workspace_write . is_some ( )
@@ -2885,29 +2836,8 @@ impl Config {
28852836 ) ;
28862837 permission_profile = PermissionProfile :: read_only ( ) ;
28872838 }
2888- let ( mut file_system_sandbox_policy, network_sandbox_policy ) =
2839+ let ( file_system_sandbox_policy, _network_sandbox_policy ) =
28892840 permission_profile. to_runtime_permissions ( ) ;
2890- let materialized_file_system_sandbox_policy = permission_profile
2891- . clone ( )
2892- . materialize_project_roots_with_workspace_roots ( & workspace_roots)
2893- . file_system_sandbox_policy ( ) ;
2894- if matches ! ( permission_profile. enforcement( ) , SandboxEnforcement :: Managed )
2895- && materialized_file_system_sandbox_policy. can_write_path_with_cwd (
2896- resolved_cwd. as_path ( ) ,
2897- resolved_cwd. as_path ( ) ,
2898- )
2899- && !materialized_file_system_sandbox_policy. has_full_disk_write_access ( )
2900- {
2901- // Keep Codex runtime write access while storing the runtime
2902- // workspace roots separately on the thread.
2903- file_system_sandbox_policy = file_system_sandbox_policy
2904- . with_additional_legacy_workspace_writable_roots ( & internal_writable_roots) ;
2905- permission_profile = PermissionProfile :: from_runtime_permissions_with_enforcement (
2906- permission_profile. enforcement ( ) ,
2907- & file_system_sandbox_policy,
2908- network_sandbox_policy,
2909- ) ;
2910- }
29112841 (
29122842 configured_network_proxy_config,
29132843 permission_profile,
@@ -3324,11 +3254,14 @@ impl Config {
33243254 network_requirements,
33253255 & network_permission_profile,
33263256 ) ?;
3327- let helper_readable_roots = get_readable_roots_required_for_codex_runtime (
3257+ let mut helper_readable_roots = get_readable_roots_required_for_codex_runtime (
33283258 & codex_home,
33293259 zsh_path. as_ref ( ) ,
33303260 main_execve_wrapper_exe. as_ref ( ) ,
33313261 ) ;
3262+ if features. enabled ( Feature :: MemoryTool ) && memories_config. use_memories {
3263+ helper_readable_roots. push ( memories_root) ;
3264+ }
33323265 let effective_permission_profile = constrained_permission_profile. value . get ( ) . clone ( ) ;
33333266 let ( mut effective_file_system_sandbox_policy, effective_network_sandbox_policy) =
33343267 effective_permission_profile. to_runtime_permissions ( ) ;
@@ -3438,7 +3371,7 @@ impl Config {
34383371 agent_max_threads,
34393372 agent_max_depth,
34403373 agent_roles,
3441- memories : cfg . memories . unwrap_or_default ( ) . into ( ) ,
3374+ memories : memories_config ,
34423375 agent_job_max_runtime_seconds,
34433376 agent_interrupt_message_enabled,
34443377 codex_home,
0 commit comments