Skip to content

core tests: migrate tools tests to permission profiles#20027

Open
bolinfest wants to merge 1 commit intopr20026from
pr20027
Open

core tests: migrate tools tests to permission profiles#20027
bolinfest wants to merge 1 commit intopr20026from
pr20027

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Apr 28, 2026

Summary

This continues the test-side migration away from SandboxPolicy by removing the remaining legacy policy setup in core/tests/suite/tools.rs. The affected test was already modeling a profile-backed filesystem policy with a deny-read glob, so configuring the test through Permissions::set_permission_profile() is a better match for the behavior being exercised.

Changes

  • Drops the SandboxPolicy import from core/tests/suite/tools.rs.
  • Configures the glob deny-read shell test directly with a PermissionProfile instead of creating a legacy read-only policy first.
  • Submits the test turn with the session permission profile so the deny-read glob remains active for the command under test.

Verification

  • cargo check -p codex-core --tests

Stack created with Sapling. Best reviewed with ReviewStack.

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

💡 Codex Review

|| network.allow_upstream_proxy == Some(true)

P1 Badge Treat disabled upstream proxy as requiring managed proxy

profile_network_requires_proxy decides whether a selected permissions profile starts the managed network proxy, but this branch only considers allow_upstream_proxy == Some(true) as proxy-relevant. Since allow_upstream_proxy defaults to true, a profile that sets network.enabled = true with allow_upstream_proxy = false (and no other proxy fields) now returns false here, so no proxy is started and that explicit upstream-proxy restriction is silently dropped.


) && !current_permission_profile
.file_system_sandbox_policy()
.can_write_path_with_cwd(cwd, cwd)
&& current_permission_profile.network_sandbox_policy()

P2 Badge Require zero writable roots before marking preset read-only

The read-only preset matcher only checks that the current profile cannot write cwd, but it does not ensure there are no writable roots elsewhere. A custom managed profile that can write outside the workspace (for example an explicit external writable path) will still be shown as “Read Only (current)”, which misstates the active permissions and can mislead users about write safety.

ℹ️ 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".

bolinfest added a commit that referenced this pull request Apr 28, 2026
## Why

The migration away from `SandboxPolicy` needs new configs to start from
permissions profiles instead of deriving profiles from legacy sandbox
modes. Existing users can have empty `config.toml` files, and we should
not rewrite user-owned config files that may live in shared
repositories.

This PR introduces built-in profile names so an empty config can resolve
to a canonical `PermissionProfile`, while explicit named `[permissions]`
profiles still behave predictably.

## What changed

- Adds built-in `default_permissions` profile names:
  - `:read-only` maps to `PermissionProfile::read_only()`.
- `:workspace` maps to the workspace-write profile, including
project-root metadata carveouts.
- `:danger-no-sandbox` maps to `PermissionProfile::Disabled`, preserving
the distinction between no sandbox and a broad managed sandbox.
- Reserves the `:` prefix for built-in profiles so user-defined
`[permissions]` profiles cannot collide with future built-ins.
- Allows `default_permissions` to reference a built-in profile without
requiring a `[permissions]` table.
- Makes an otherwise empty config choose a built-in profile by
trust/platform context: trusted or untrusted project roots use
`:workspace` when the platform supports that sandbox, while roots
without a trust decision use `:read-only`.
- Keeps legacy `sandbox_mode` configs on the legacy path, and still
rejects user-defined `[permissions]` profiles that omit
`default_permissions` so we do not silently guess among custom profiles.
- Preserves compatibility behavior for implicit defaults: bare
`network.enabled = true` allows runtime network without starting the
managed proxy, explicit profile proxy policy still starts the proxy, and
implicit workspace/add-dir roots keep legacy metadata carveouts.

## Verification

- `cargo test -p codex-core builtin --lib`
- `cargo test -p codex-core profile_network_proxy_config`
- `cargo test -p codex-core
implicit_builtin_workspace_profile_preserves_add_dir_metadata_carveouts`
- `cargo test -p codex-core
permissions_profiles_network_enabled_allows_runtime_network_without_proxy`
- `cargo test -p codex-core
permissions_profiles_proxy_policy_starts_managed_network_proxy`

## Documentation

Public Codex config docs should mention these built-in names when the
`[permissions]` config format is ready to document as stable.









---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/19900).
* #20041
* #20040
* #20037
* #20035
* #20034
* #20033
* #20032
* #20030
* #20028
* #20027
* #20026
* #20024
* #20021
* #20018
* #20016
* #20015
* #20013
* #20011
* #20010
* #20008
* __->__ #19900
@bolinfest bolinfest force-pushed the pr20027 branch 3 times, most recently from 9db1f09 to bb289b0 Compare April 28, 2026 20:02
@bolinfest bolinfest force-pushed the pr20027 branch 2 times, most recently from 4cf7d13 to b8e1095 Compare April 28, 2026 20:18
bolinfest added a commit that referenced this pull request Apr 28, 2026
## Summary
- Move TUI permission state from legacy `SandboxPolicy` values to
canonical `PermissionProfile` values across presets, app events, chat
widget state, app commands, thread routing, and cached thread session
state.
- Keep app-server compatibility boundaries explicit: embedded sessions
send `permissionProfile`, while remote sessions send only a legacy
`sandbox` projection and fall back to read-only when a custom profile
cannot be projected.
- Update status/add-dir UI summaries and snapshots to render the active
permission profile, including workspace profiles selected by the new
built-in defaults.

## Verification
- `rg '\bSandboxPolicy\b' codex-rs/tui -n` returns no matches.
- `cargo test -p codex-tui`
- `cargo check -p codex-tui --tests`
- `cargo test -p codex-tui additional_dirs`
- `just fmt`
- `just fix -p codex-tui`




































---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/20008).
* #20041
* #20040
* #20037
* #20035
* #20034
* #20033
* #20032
* #20030
* #20028
* #20027
* #20026
* #20024
* #20021
* #20018
* #20016
* #20015
* #20013
* #20011
* #20010
* __->__ #20008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant