Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f858b35bc1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let (mut file_system_sandbox_policy, network_sandbox_policy) = | ||
| permission_profile.to_runtime_permissions(); |
There was a problem hiding this comment.
Restore cwd projection for legacy sandbox defaults
Converting legacy sandbox_mode defaults with permission_profile.to_runtime_permissions() changes workspace-write behavior: PermissionProfile::workspace_write() carries unconditional project_roots(".git") / project_roots(".agents") read rules, so ${cwd}/.git and ${cwd}/.agents become read-only even when they do not exist yet. The previous path (from_legacy_sandbox_policy_for_cwd) only added those carveouts when present on disk (except .codex), so operations like git init in a fresh directory could create .git. This regression can block common write flows under legacy workspace-write configs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in c70c0f5c94. Config loading now projects the derived profile through to_legacy_sandbox_policy(resolved_cwd) and rehydrates it with PermissionProfile::from_legacy_sandbox_policy_for_cwd(...), so legacy workspace-write keeps the cwd-aware .git / .agents behavior. Coverage includes legacy_sandbox_mode_builds_profiles_with_compatible_projection and with_additional_legacy_workspace_writable_roots_protects_metadata.
c188a22 to
c70c0f5
Compare
- anomalyco/opencode#24574 ignore: split up reasoning transforms (merge-as-is) - anomalyco/opencode#24573 fix: vertex anthropic toolStreaming default (merge-as-is) - openai/codex#19778 hooks/list + hooks/config/write APIs (merge-after-nits) - openai/codex#19772 permissions: derive config defaults as profiles (merge-after-nits)
4b88857 to
e103c1c
Compare
Why
This continues the permissions migration by making legacy config default resolution produce the canonical
PermissionProfilefirst. The legacySandboxPolicyprojection should stay available at compatibility boundaries, but config loading should not create a legacy policy just to immediately convert it back into a profile.Specifically, when
default_permissionsis not specified inconfig.toml, instead of creating aSandboxPolicyincodex-rs/core/src/config/mod.rsand then trying to derive aPermissionProfilefrom it, we usederive_permission_profile()to create a more faithfulPermissionProfileusing the values ofConfigTomldirectly.This also keeps the existing behavior of
sandbox_workspace_writeand extra writable roots after #19841 replaced:cwdwith:project_roots. Legacy workspace-write defaults are represented as symbolic:project_rootswrite access plus symbolic project-root metadata carveouts. Extra absolute writable roots are still added directly and continue to get concrete metadata protections for paths that exist under those roots.The platform sandboxes differ when a symbolic project-root subpath does not exist yet.
.git,.agents, or.codexdo not exist./dev/nullto a missing.gitcan create a host-visible placeholder that changes Git repo discovery. Binding missing.agentswould not affect Git discovery, but it would still create a host-visible project metadata placeholder from an automatic compatibility carveout. Linux therefore skips only missing automatic.gitand.agentsread-only metadata masks; missing.codexremains protected so first-time project config creation goes through the protected-path approval flow. User-authoredreadandnonesubpath rules keep normal bwrap behavior, andnonecan still mask the first missing component to prevent creation under writable roots.What Changed
PermissionProfile::workspace_write_with(),FileSystemSandboxPolicy::workspace_write(), andFileSystemSandboxPolicy::with_additional_legacy_workspace_writable_roots().FileSystemSandboxPolicy::workspace_write()the single legacy workspace-write constructor so bothfrom_legacy_sandbox_policy()andFrom<&SandboxPolicy>include the project-root metadata carveouts.legacy_workspace_write_base_policy()path and theprune_read_entries_under_writable_roots()cleanup that was only needed by that split construction.ConfigToml::derive_permission_profile()for legacy sandbox-mode fallback resolution; nameddefault_permissionsprofiles continue through the permissions profile pipeline instead of being reconstructed fromsandbox_mode.Config::load()to start from the derived profile, validate that it still has a legacy compatibility projection, and apply additional writable roots directly to managed workspace-write filesystem policies..git/.agentssymbolic project-root read-only carveouts are skipped before emitting bind args; missing.codex, user-authoredread/nonesubpath rules, and existing missing writable-root behavior are preserved..git, and bwrap skips missing.git/.agentsproject-root carveouts while preserving missing.codexand user-authored missing subpath rules.Stack created with Sapling. Best reviewed with ReviewStack.