Read turn permissions from the current configuration (#36930)

## What changed

- Remove the cached permission profile from `TurnContext` and derive the
  effective profile, filesystem policy, network policy, and legacy sandbox
  policy from `config.permissions`.
- Update sandbox consumers and tests to use the current turn configuration.
- Verify that role-based agent spawning reapplies runtime permissions and that
  cold-resumed agents retain their disabled permission profile.

GitOrigin-RevId: d67c5d2bcbe6dc76f15b56defb485b155fd1f138
This commit is contained in:
jif authored and copyberry committed 2026-08-04 17:13:13 +00:00
1 parent 7ada37a15e
commit 90314a9207
14 files changed
+67 -40

No files matched your search

+1 -1
View File
@@ -244,7 +244,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
fn parent_turn_denied_reads_context(turn: &TurnContext) -> Option<String> {
#[allow(deprecated)]
let cwd = &turn.cwd;
let file_system_policy = turn.permission_profile.file_system_sandbox_policy();
let file_system_policy = turn.file_system_sandbox_policy();
let mut entries = file_system_policy
.get_unreadable_roots_with_cwd(cwd)
.into_iter()
+5 -1
View File
@@ -467,7 +467,7 @@ async fn build_guardian_prompt_includes_parent_turn_denied_reads() -> anyhow::Re
session.thread_id = fixed_guardian_parent_session_id();
let denied_root = test_path_buf("/repo/private").abs();
let denied_glob = test_path_buf("/repo/private/**").display().to_string();
turn.permission_profile = PermissionProfile::from_runtime_permissions(
let permission_profile = PermissionProfile::from_runtime_permissions(
&FileSystemSandboxPolicy::restricted(vec![
FileSystemSandboxEntry {
path: FileSystemPath::Special {
@@ -493,6 +493,10 @@ async fn build_guardian_prompt_includes_parent_turn_denied_reads() -> anyhow::Re
]),
NetworkSandboxPolicy::Restricted,
);
Arc::make_mut(&mut turn.config)
.permissions
.set_permission_profile(permission_profile)
.expect("test setup should allow updating permission profile");
let session = Arc::new(session);
let turn = Arc::new(turn);
seed_guardian_parent_history(&session, &turn).await;