Skip to content

core: preserve constrained approval/sandbox policies in TurnContext#12473

Merged
bolinfest merged 1 commit intomainfrom
pr12473
Feb 21, 2026
Merged

core: preserve constrained approval/sandbox policies in TurnContext#12473
bolinfest merged 1 commit intomainfrom
pr12473

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Feb 21, 2026

Why

Config.permissions stores approval_policy and sandbox_policy as Constrained<...>, and that wrapper is part of the safety guarantee.

TurnContext was converting those fields to raw AskForApproval / SandboxPolicy values, so code operating on TurnContext no longer had a guarantee that the per-turn policies still honored the original constraints.

This change preserves the Constrained wrappers in TurnContext so turn-level policy data carries the same guarantees as Permissions.

Admittedly, there are still other types that maintain a reference to the raw value (such as ExecApprovalRequest), but we'll defer changing that to subsequent PRs.

What Changed

  • Changed TurnContext.approval_policy and TurnContext.sandbox_policy to Constrained<...>.
  • Updated TurnContext construction to clone the constrained values from session/config state instead of stripping them to raw values.
  • Updated downstream call sites to explicitly read .value() / .get() only where raw policy values are required (tool orchestration, safety checks, MCP/network checks, and context serialization/diffing).
  • Updated tests/helpers that mutate turn policies to call .set(...) on the constrained wrappers.

Verification

  • cargo check -p codex-core
  • cargo test -p codex-core (local run failed only in unrelated skills::loader tests due extra user-scoped skills present in this environment; touched codex, unified_exec, multi_agents, and js_repl tests passed)

@bolinfest bolinfest changed the title fix: update approval_policy and sandbox_policy in TurnContext to be Constrained core: preserve constrained approval/sandbox policies in TurnContext Feb 21, 2026
@bolinfest bolinfest merged commit 66d5d34 into main Feb 21, 2026
33 checks passed
@bolinfest bolinfest deleted the pr12473 branch February 21, 2026 22:40
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 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