Skip to content

permissions: derive legacy exec policies at boundaries#19737

Merged
bolinfest merged 1 commit intomainfrom
pr19737
Apr 27, 2026
Merged

permissions: derive legacy exec policies at boundaries#19737
bolinfest merged 1 commit intomainfrom
pr19737

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Apr 27, 2026

Why

After config and requirements store canonical profiles, exec requests should not cache a derived SandboxPolicy. The cached legacy value can drift from the richer profile state, and most execution paths already have the filesystem and network runtime policies they need.

What Changed

  • Removes sandbox_policy from codex_sandboxing::SandboxExecRequest and codex_core::sandboxing::ExecRequest.
  • Adds an on-demand ExecRequest::compatibility_sandbox_policy() helper for the Windows and legacy call sites that still need a SandboxPolicy projection.
  • Updates Windows filesystem override setup and unified exec policy serialization to derive that compatibility policy at the boundary.
  • Updates Unix escalation reruns and direct shell requests to reconstruct exec requests from PermissionProfile plus runtime filesystem/network policy, without carrying a cached legacy policy.
  • Adjusts sandboxing manager tests to assert the effective profile rather than the removed legacy field.

Verification

  • cargo check -p codex-config -p codex-core -p codex-sandboxing -p codex-app-server -p codex-cli -p codex-tui
  • cargo test -p codex-sandboxing manager
  • cargo test -p codex-core exec_server_params_use_env_policy_overlay_contract
  • cargo test -p codex-core unix_escalation
  • cargo test -p codex-core exec::tests
  • cargo test -p codex-core sandboxing::tests

@bolinfest bolinfest requested a review from a team as a code owner April 27, 2026 00:40
bolinfest added a commit that referenced this pull request Apr 27, 2026
## Why

Several execution paths still converted profile-backed permissions into
`SandboxPolicy` and then rebuilt runtime permissions from that legacy
shape. Those round trips are unnecessary after the preceding PRs and can
lose split filesystem semantics. Core approval and escalation should
carry the resolved profile directly.

## What Changed

- Removes `sandbox_policy` from `ResolvedPermissionProfile`; the
resolved permission object now carries the canonical `PermissionProfile`
directly.
- Updates exec-policy fallback, shell/unified-exec interception,
escalation reruns, and related tests to pass profiles instead of legacy
policies.
- Removes legacy additional-permission merge helpers that built an
effective `SandboxPolicy` before rebuilding runtime permissions.
- Keeps legacy projections only at compatibility boundaries that still
require `SandboxPolicy`, not in core permission computation.

## Verification

- `cargo test -p codex-core direct_write_roots`
- `cargo test -p codex-core runtime_roots_to_legacy_projection`
- `cargo test -p codex-app-server
requested_permissions_trust_project_uses_permission_profile_intent`







































































---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/19394).
* #19737
* #19736
* #19735
* #19734
* #19395
* __->__ #19394
@bolinfest bolinfest force-pushed the pr19736 branch 2 times, most recently from 95ba6f8 to fc3c6bf Compare April 27, 2026 02:30
bolinfest added a commit that referenced this pull request Apr 27, 2026
## Why

The remaining migration work still needs `SandboxPolicy` at a few
compatibility boundaries, but those projections should come from one
canonical path. Keeping ad hoc legacy projections scattered through
app-server, CLI, and config code makes it easy for behavior to drift as
`PermissionProfile` gains fidelity that the legacy enum cannot
represent.

## What Changed

- Adds `Permissions::legacy_sandbox_policy(cwd)` and
`Config::legacy_sandbox_policy()` as the compatibility projection from
the canonical `PermissionProfile`.
- Adds `Permissions::can_set_legacy_sandbox_policy()` so legacy inputs
are checked after they are converted into profile semantics.
- Updates app-server command handling, Windows sandbox setup, session
configuration, and sandbox summaries to use the centralized projection
helper.
- Leaves `SandboxPolicy` in place only for boundary inputs/outputs that
still speak the legacy abstraction.

## Verification

- `cargo check -p codex-config -p codex-core -p codex-sandboxing -p
codex-app-server -p codex-cli -p codex-tui`
- `cargo test -p codex-tui
permissions_selection_history_snapshot_full_access_to_default --
--nocapture`
- `cargo test -p codex-tui
permissions_selection_sends_approvals_reviewer_in_override_turn_context
-- --nocapture`
- `bazel test //codex-rs/tui:tui-unit-tests-bin
--test_arg=permissions_selection_history_snapshot_full_access_to_default
--test_output=errors`
- `bazel test //codex-rs/tui:tui-unit-tests-bin
--test_arg=permissions_selection_sends_approvals_reviewer_in_override_turn_context
--test_output=errors`


---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/19734).
* #19737
* #19736
* #19735
* __->__ #19734
@bolinfest bolinfest force-pushed the pr19737 branch 2 times, most recently from b573755 to b64e389 Compare April 27, 2026 04:01
Base automatically changed from pr19736 to main April 27, 2026 04:49
@bolinfest bolinfest merged commit a6ca39c into main Apr 27, 2026
39 of 50 checks passed
@bolinfest bolinfest deleted the pr19737 branch April 27, 2026 05:11
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants