Skip to content

permissions: constrain requirements as profiles#19736

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

permissions: constrain requirements as profiles#19736
bolinfest merged 1 commit intomainfrom
pr19736

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Apr 27, 2026

Why

Requirements are the other place where the old sandbox abstraction can still constrain runtime behavior. If allowed_sandbox_modes validates through SandboxPolicy, profile-backed configurations can be rejected or lossy even though the runtime can now carry and enforce the richer profile directly.

What Changed

  • Replaces ConfigRequirements::sandbox_policy with ConfigRequirements::permission_profile.
  • Converts allowed_sandbox_modes into a Constrained<PermissionProfile> by classifying profiles into the existing sandbox-mode requirement buckets.
  • Applies config requirements directly to the loaded PermissionProfile instead of projecting through a strict legacy bridge.
  • Preserves configured deny-read restrictions when requirements narrow the active profile, then reapplies helper-readable roots to the final effective profile.
  • Updates /debug-config requirement-source output to report the profile-backed requirement source.

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-config
  • cargo test -p codex-core config::config_loader_tests
  • cargo test -p codex-core config::tests::requirements
  • cargo test -p codex-core derive_sandbox_policy
  • cargo test -p codex-core permission_profile_override
  • cargo test -p codex-tui debug_config_output_lists_requirement_sources

Stack created with Sapling. Best reviewed with ReviewStack.

@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 requested a review from viyatb-oai April 27, 2026 01:19
@bolinfest bolinfest force-pushed the pr19736 branch 2 times, most recently from d3d674b to 4a813f1 Compare April 27, 2026 01:54
@bolinfest bolinfest force-pushed the pr19736 branch 2 times, most recently from 95ba6f8 to fc3c6bf Compare April 27, 2026 02:30
@bolinfest bolinfest force-pushed the pr19735 branch 2 times, most recently from be50c03 to 19884cb Compare April 27, 2026 03:01
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
Base automatically changed from pr19735 to main April 27, 2026 04:00
@bolinfest bolinfest merged commit 523e4aa into main Apr 27, 2026
49 of 50 checks passed
@bolinfest bolinfest deleted the pr19736 branch April 27, 2026 04:49
@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