Avoid exposing full permission profile

This commit is contained in:
Eric Traut
2026-05-19 08:49:02 -07:00
parent 62df4d9f9e
commit a9fd5c35e1
14 changed files with 15 additions and 884 deletions
@@ -2178,57 +2178,6 @@
],
"type": "object"
},
"ManagedFileSystemPermissions": {
"oneOf": [
{
"properties": {
"entries": {
"items": {
"$ref": "#/definitions/FileSystemSandboxEntry"
},
"type": "array"
},
"globScanMaxDepth": {
"format": "uint",
"minimum": 1.0,
"type": [
"integer",
"null"
]
},
"type": {
"enum": [
"restricted"
],
"title": "RestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"entries",
"type"
],
"title": "RestrictedManagedFileSystemPermissions",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"unrestricted"
],
"title": "UnrestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"type"
],
"title": "UnrestrictedManagedFileSystemPermissions",
"type": "object"
}
]
},
"McpServerOauthLoginCompletedNotification": {
"properties": {
"error": {
@@ -2488,13 +2437,6 @@
],
"type": "string"
},
"NetworkSandboxPolicy": {
"enum": [
"enabled",
"restricted"
],
"type": "string"
},
"NonSteerableTurnKind": {
"enum": [
"review",
@@ -2569,70 +2511,6 @@
}
]
},
"PermissionProfile": {
"oneOf": [
{
"properties": {
"fileSystem": {
"$ref": "#/definitions/ManagedFileSystemPermissions"
},
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"managed"
],
"title": "ManagedPermissionProfileType",
"type": "string"
}
},
"required": [
"fileSystem",
"network",
"type"
],
"title": "ManagedPermissionProfile",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"disabled"
],
"title": "DisabledPermissionProfileType",
"type": "string"
}
},
"required": [
"type"
],
"title": "DisabledPermissionProfile",
"type": "object"
},
{
"properties": {
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"external"
],
"title": "ExternalPermissionProfileType",
"type": "string"
}
},
"required": [
"network",
"type"
],
"title": "ExternalPermissionProfile",
"type": "object"
}
]
},
"Personality": {
"enum": [
"none",
@@ -4574,9 +4452,6 @@
"modelProvider": {
"type": "string"
},
"permissionProfile": {
"$ref": "#/definitions/PermissionProfile"
},
"personality": {
"anyOf": [
{
@@ -4614,7 +4489,6 @@
"cwd",
"model",
"modelProvider",
"permissionProfile",
"sandboxPolicy"
],
"type": "object"
@@ -10461,57 +10461,6 @@
"title": "LogoutAccountResponse",
"type": "object"
},
"ManagedFileSystemPermissions": {
"oneOf": [
{
"properties": {
"entries": {
"items": {
"$ref": "#/definitions/v2/FileSystemSandboxEntry"
},
"type": "array"
},
"globScanMaxDepth": {
"format": "uint",
"minimum": 1.0,
"type": [
"integer",
"null"
]
},
"type": {
"enum": [
"restricted"
],
"title": "RestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"entries",
"type"
],
"title": "RestrictedManagedFileSystemPermissions",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"unrestricted"
],
"title": "UnrestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"type"
],
"title": "UnrestrictedManagedFileSystemPermissions",
"type": "object"
}
]
},
"ManagedHooksRequirements": {
"properties": {
"PermissionRequest": {
@@ -11623,13 +11572,6 @@
},
"type": "object"
},
"NetworkSandboxPolicy": {
"enum": [
"enabled",
"restricted"
],
"type": "string"
},
"NetworkUnixSocketPermission": {
"enum": [
"allow",
@@ -11728,70 +11670,6 @@
}
]
},
"PermissionProfile": {
"oneOf": [
{
"properties": {
"fileSystem": {
"$ref": "#/definitions/v2/ManagedFileSystemPermissions"
},
"network": {
"$ref": "#/definitions/v2/NetworkSandboxPolicy"
},
"type": {
"enum": [
"managed"
],
"title": "ManagedPermissionProfileType",
"type": "string"
}
},
"required": [
"fileSystem",
"network",
"type"
],
"title": "ManagedPermissionProfile",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"disabled"
],
"title": "DisabledPermissionProfileType",
"type": "string"
}
},
"required": [
"type"
],
"title": "DisabledPermissionProfile",
"type": "object"
},
{
"properties": {
"network": {
"$ref": "#/definitions/v2/NetworkSandboxPolicy"
},
"type": {
"enum": [
"external"
],
"title": "ExternalPermissionProfileType",
"type": "string"
}
},
"required": [
"network",
"type"
],
"title": "ExternalPermissionProfile",
"type": "object"
}
]
},
"Personality": {
"enum": [
"none",
@@ -17241,9 +17119,6 @@
"modelProvider": {
"type": "string"
},
"permissionProfile": {
"$ref": "#/definitions/v2/PermissionProfile"
},
"personality": {
"anyOf": [
{
@@ -17281,7 +17156,6 @@
"cwd",
"model",
"modelProvider",
"permissionProfile",
"sandboxPolicy"
],
"type": "object"
@@ -6990,57 +6990,6 @@
"title": "LogoutAccountResponse",
"type": "object"
},
"ManagedFileSystemPermissions": {
"oneOf": [
{
"properties": {
"entries": {
"items": {
"$ref": "#/definitions/FileSystemSandboxEntry"
},
"type": "array"
},
"globScanMaxDepth": {
"format": "uint",
"minimum": 1.0,
"type": [
"integer",
"null"
]
},
"type": {
"enum": [
"restricted"
],
"title": "RestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"entries",
"type"
],
"title": "RestrictedManagedFileSystemPermissions",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"unrestricted"
],
"title": "UnrestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"type"
],
"title": "UnrestrictedManagedFileSystemPermissions",
"type": "object"
}
]
},
"ManagedHooksRequirements": {
"properties": {
"PermissionRequest": {
@@ -8152,13 +8101,6 @@
},
"type": "object"
},
"NetworkSandboxPolicy": {
"enum": [
"enabled",
"restricted"
],
"type": "string"
},
"NetworkUnixSocketPermission": {
"enum": [
"allow",
@@ -8257,70 +8199,6 @@
}
]
},
"PermissionProfile": {
"oneOf": [
{
"properties": {
"fileSystem": {
"$ref": "#/definitions/ManagedFileSystemPermissions"
},
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"managed"
],
"title": "ManagedPermissionProfileType",
"type": "string"
}
},
"required": [
"fileSystem",
"network",
"type"
],
"title": "ManagedPermissionProfile",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"disabled"
],
"title": "DisabledPermissionProfileType",
"type": "string"
}
},
"required": [
"type"
],
"title": "DisabledPermissionProfile",
"type": "object"
},
{
"properties": {
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"external"
],
"title": "ExternalPermissionProfileType",
"type": "string"
}
},
"required": [
"network",
"type"
],
"title": "ExternalPermissionProfile",
"type": "object"
}
]
},
"Personality": {
"enum": [
"none",
@@ -15065,9 +14943,6 @@
"modelProvider": {
"type": "string"
},
"permissionProfile": {
"$ref": "#/definitions/PermissionProfile"
},
"personality": {
"anyOf": [
{
@@ -15105,7 +14980,6 @@
"cwd",
"model",
"modelProvider",
"permissionProfile",
"sandboxPolicy"
],
"type": "object"
@@ -100,253 +100,6 @@
],
"type": "object"
},
"FileSystemAccessMode": {
"enum": [
"read",
"write",
"none"
],
"type": "string"
},
"FileSystemPath": {
"oneOf": [
{
"properties": {
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
},
"type": {
"enum": [
"path"
],
"title": "PathFileSystemPathType",
"type": "string"
}
},
"required": [
"path",
"type"
],
"title": "PathFileSystemPath",
"type": "object"
},
{
"properties": {
"pattern": {
"type": "string"
},
"type": {
"enum": [
"glob_pattern"
],
"title": "GlobPatternFileSystemPathType",
"type": "string"
}
},
"required": [
"pattern",
"type"
],
"title": "GlobPatternFileSystemPath",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"special"
],
"title": "SpecialFileSystemPathType",
"type": "string"
},
"value": {
"$ref": "#/definitions/FileSystemSpecialPath"
}
},
"required": [
"type",
"value"
],
"title": "SpecialFileSystemPath",
"type": "object"
}
]
},
"FileSystemSandboxEntry": {
"properties": {
"access": {
"$ref": "#/definitions/FileSystemAccessMode"
},
"path": {
"$ref": "#/definitions/FileSystemPath"
}
},
"required": [
"access",
"path"
],
"type": "object"
},
"FileSystemSpecialPath": {
"oneOf": [
{
"properties": {
"kind": {
"enum": [
"root"
],
"type": "string"
}
},
"required": [
"kind"
],
"title": "RootFileSystemSpecialPath",
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"minimal"
],
"type": "string"
}
},
"required": [
"kind"
],
"title": "MinimalFileSystemSpecialPath",
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"project_roots"
],
"type": "string"
},
"subpath": {
"type": [
"string",
"null"
]
}
},
"required": [
"kind"
],
"title": "KindFileSystemSpecialPath",
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"tmpdir"
],
"type": "string"
}
},
"required": [
"kind"
],
"title": "TmpdirFileSystemSpecialPath",
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"slash_tmp"
],
"type": "string"
}
},
"required": [
"kind"
],
"title": "SlashTmpFileSystemSpecialPath",
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"unknown"
],
"type": "string"
},
"path": {
"type": "string"
},
"subpath": {
"type": [
"string",
"null"
]
}
},
"required": [
"kind",
"path"
],
"type": "object"
}
]
},
"ManagedFileSystemPermissions": {
"oneOf": [
{
"properties": {
"entries": {
"items": {
"$ref": "#/definitions/FileSystemSandboxEntry"
},
"type": "array"
},
"globScanMaxDepth": {
"format": "uint",
"minimum": 1.0,
"type": [
"integer",
"null"
]
},
"type": {
"enum": [
"restricted"
],
"title": "RestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"entries",
"type"
],
"title": "RestrictedManagedFileSystemPermissions",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"unrestricted"
],
"title": "UnrestrictedManagedFileSystemPermissionsType",
"type": "string"
}
},
"required": [
"type"
],
"title": "UnrestrictedManagedFileSystemPermissions",
"type": "object"
}
]
},
"ModeKind": {
"description": "Initial collaboration mode to use when the TUI starts.",
"enum": [
@@ -362,77 +115,6 @@
],
"type": "string"
},
"NetworkSandboxPolicy": {
"enum": [
"enabled",
"restricted"
],
"type": "string"
},
"PermissionProfile": {
"oneOf": [
{
"properties": {
"fileSystem": {
"$ref": "#/definitions/ManagedFileSystemPermissions"
},
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"managed"
],
"title": "ManagedPermissionProfileType",
"type": "string"
}
},
"required": [
"fileSystem",
"network",
"type"
],
"title": "ManagedPermissionProfile",
"type": "object"
},
{
"properties": {
"type": {
"enum": [
"disabled"
],
"title": "DisabledPermissionProfileType",
"type": "string"
}
},
"required": [
"type"
],
"title": "DisabledPermissionProfile",
"type": "object"
},
{
"properties": {
"network": {
"$ref": "#/definitions/NetworkSandboxPolicy"
},
"type": {
"enum": [
"external"
],
"title": "ExternalPermissionProfileType",
"type": "string"
}
},
"required": [
"network",
"type"
],
"title": "ExternalPermissionProfile",
"type": "object"
}
]
},
"Personality": {
"enum": [
"none",
@@ -640,9 +322,6 @@
"modelProvider": {
"type": "string"
},
"permissionProfile": {
"$ref": "#/definitions/PermissionProfile"
},
"personality": {
"anyOf": [
{
@@ -680,7 +359,6 @@
"cwd",
"model",
"modelProvider",
"permissionProfile",
"sandboxPolicy"
],
"type": "object"
@@ -1,6 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FileSystemSandboxEntry } from "./FileSystemSandboxEntry";
export type ManagedFileSystemPermissions = { "type": "restricted", entries: Array<FileSystemSandboxEntry>, globScanMaxDepth?: number, } | { "type": "unrestricted" };
@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type NetworkSandboxPolicy = "enabled" | "restricted";
@@ -1,7 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ManagedFileSystemPermissions } from "./ManagedFileSystemPermissions";
import type { NetworkSandboxPolicy } from "./NetworkSandboxPolicy";
export type PermissionProfile = { "type": "managed", fileSystem: ManagedFileSystemPermissions, network: NetworkSandboxPolicy, } | { "type": "disabled" } | { "type": "external", network: NetworkSandboxPolicy, };
@@ -9,7 +9,6 @@ import type { ReasoningSummary } from "../ReasoningSummary";
import type { ActivePermissionProfile } from "./ActivePermissionProfile";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
import type { PermissionProfile } from "./PermissionProfile";
import type { SandboxPolicy } from "./SandboxPolicy";
export type ThreadSettings = { model: string, modelProvider: string, serviceTier: string | null, cwd: AbsolutePathBuf, approvalPolicy: AskForApproval, approvalsReviewer: ApprovalsReviewer, sandboxPolicy: SandboxPolicy, permissionProfile: PermissionProfile, activePermissionProfile: ActivePermissionProfile | null, effort: ReasoningEffort | null, summary: ReasoningSummary | null, personality: Personality | null, collaborationMode: CollaborationMode, };
export type ThreadSettings = { model: string, modelProvider: string, serviceTier: string | null, cwd: AbsolutePathBuf, approvalPolicy: AskForApproval, approvalsReviewer: ApprovalsReviewer, sandboxPolicy: SandboxPolicy, activePermissionProfile: ActivePermissionProfile | null, effort: ReasoningEffort | null, summary: ReasoningSummary | null, personality: Personality | null, collaborationMode: CollaborationMode, };
@@ -173,7 +173,6 @@ export type { ListMcpServerStatusResponse } from "./ListMcpServerStatusResponse"
export type { LoginAccountParams } from "./LoginAccountParams";
export type { LoginAccountResponse } from "./LoginAccountResponse";
export type { LogoutAccountResponse } from "./LogoutAccountResponse";
export type { ManagedFileSystemPermissions } from "./ManagedFileSystemPermissions";
export type { ManagedHooksRequirements } from "./ManagedHooksRequirements";
export type { MarketplaceAddParams } from "./MarketplaceAddParams";
export type { MarketplaceAddResponse } from "./MarketplaceAddResponse";
@@ -250,14 +249,12 @@ export type { NetworkDomainPermission } from "./NetworkDomainPermission";
export type { NetworkPolicyAmendment } from "./NetworkPolicyAmendment";
export type { NetworkPolicyRuleAction } from "./NetworkPolicyRuleAction";
export type { NetworkRequirements } from "./NetworkRequirements";
export type { NetworkSandboxPolicy } from "./NetworkSandboxPolicy";
export type { NetworkUnixSocketPermission } from "./NetworkUnixSocketPermission";
export type { NonSteerableTurnKind } from "./NonSteerableTurnKind";
export type { OverriddenMetadata } from "./OverriddenMetadata";
export type { PatchApplyStatus } from "./PatchApplyStatus";
export type { PatchChangeKind } from "./PatchChangeKind";
export type { PermissionGrantScope } from "./PermissionGrantScope";
export type { PermissionProfile } from "./PermissionProfile";
export type { PermissionsRequestApprovalParams } from "./PermissionsRequestApprovalParams";
export type { PermissionsRequestApprovalResponse } from "./PermissionsRequestApprovalResponse";
export type { PlanDeltaNotification } from "./PlanDeltaNotification";
@@ -1598,7 +1598,6 @@ mod tests {
approval_policy: v2::AskForApproval::OnFailure,
approvals_reviewer: v2::ApprovalsReviewer::User,
sandbox_policy: v2::SandboxPolicy::DangerFullAccess,
permission_profile: v2::PermissionProfile::Disabled,
active_permission_profile: None,
effort: None,
summary: None,
@@ -7,14 +7,11 @@ use codex_protocol::approvals::NetworkPolicyRuleAction as CoreNetworkPolicyRuleA
use codex_protocol::models::ActivePermissionProfile as CoreActivePermissionProfile;
use codex_protocol::models::AdditionalPermissionProfile as CoreAdditionalPermissionProfile;
use codex_protocol::models::FileSystemPermissions as CoreFileSystemPermissions;
use codex_protocol::models::ManagedFileSystemPermissions as CoreManagedFileSystemPermissions;
use codex_protocol::models::NetworkPermissions as CoreNetworkPermissions;
use codex_protocol::models::PermissionProfile as CorePermissionProfile;
use codex_protocol::permissions::FileSystemAccessMode as CoreFileSystemAccessMode;
use codex_protocol::permissions::FileSystemPath as CoreFileSystemPath;
use codex_protocol::permissions::FileSystemSandboxEntry as CoreFileSystemSandboxEntry;
use codex_protocol::permissions::FileSystemSpecialPath as CoreFileSystemSpecialPath;
use codex_protocol::permissions::NetworkSandboxPolicy as CoreNetworkSandboxPolicy;
use codex_protocol::protocol::NetworkAccess as CoreNetworkAccess;
use codex_protocol::request_permissions::PermissionGrantScope as CorePermissionGrantScope;
use codex_protocol::request_permissions::RequestPermissionProfile as CoreRequestPermissionProfile;
@@ -185,13 +182,6 @@ v2_enum_from_core!(
}
);
v2_enum_from_core!(
pub enum NetworkSandboxPolicy from CoreNetworkSandboxPolicy {
Enabled,
Restricted
}
);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(tag = "kind", rename_all = "snake_case")]
#[ts(tag = "kind")]
@@ -297,113 +287,6 @@ impl From<FileSystemSandboxEntry> for CoreFileSystemSandboxEntry {
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(tag = "type", rename_all = "snake_case")]
#[ts(tag = "type")]
#[ts(export_to = "v2/")]
pub enum ManagedFileSystemPermissions {
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Restricted {
entries: Vec<FileSystemSandboxEntry>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
glob_scan_max_depth: Option<NonZeroUsize>,
},
Unrestricted,
}
impl From<CoreManagedFileSystemPermissions> for ManagedFileSystemPermissions {
fn from(value: CoreManagedFileSystemPermissions) -> Self {
match value {
CoreManagedFileSystemPermissions::Restricted {
entries,
glob_scan_max_depth,
} => Self::Restricted {
entries: entries
.into_iter()
.map(FileSystemSandboxEntry::from)
.collect(),
glob_scan_max_depth,
},
CoreManagedFileSystemPermissions::Unrestricted => Self::Unrestricted,
}
}
}
impl From<ManagedFileSystemPermissions> for CoreManagedFileSystemPermissions {
fn from(value: ManagedFileSystemPermissions) -> Self {
match value {
ManagedFileSystemPermissions::Restricted {
entries,
glob_scan_max_depth,
} => Self::Restricted {
entries: entries
.into_iter()
.map(CoreFileSystemSandboxEntry::from)
.collect(),
glob_scan_max_depth,
},
ManagedFileSystemPermissions::Unrestricted => Self::Unrestricted,
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(tag = "type", rename_all = "snake_case")]
#[ts(tag = "type")]
#[ts(export_to = "v2/")]
pub enum PermissionProfile {
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Managed {
file_system: ManagedFileSystemPermissions,
network: NetworkSandboxPolicy,
},
Disabled,
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
External {
network: NetworkSandboxPolicy,
},
}
impl From<CorePermissionProfile> for PermissionProfile {
fn from(value: CorePermissionProfile) -> Self {
match value {
CorePermissionProfile::Managed {
file_system,
network,
} => Self::Managed {
file_system: file_system.into(),
network: network.into(),
},
CorePermissionProfile::Disabled => Self::Disabled,
CorePermissionProfile::External { network } => Self::External {
network: network.into(),
},
}
}
}
impl From<PermissionProfile> for CorePermissionProfile {
fn from(value: PermissionProfile) -> Self {
match value {
PermissionProfile::Managed {
file_system,
network,
} => Self::Managed {
file_system: file_system.into(),
network: network.to_core(),
},
PermissionProfile::Disabled => Self::Disabled,
PermissionProfile::External { network } => Self::External {
network: network.to_core(),
},
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
@@ -1,7 +1,6 @@
use super::ActivePermissionProfile;
use super::ApprovalsReviewer;
use super::AskForApproval;
use super::PermissionProfile;
use super::SandboxMode;
use super::SandboxPolicy;
use super::Thread;
@@ -244,7 +243,6 @@ pub struct ThreadSettings {
pub approval_policy: AskForApproval,
pub approvals_reviewer: ApprovalsReviewer,
pub sandbox_policy: SandboxPolicy,
pub permission_profile: PermissionProfile,
pub active_permission_profile: Option<ActivePermissionProfile>,
pub effort: Option<ReasoningEffort>,
pub summary: Option<ReasoningSummary>,
@@ -1475,7 +1475,6 @@ fn thread_settings_from_snapshot(config_snapshot: &ThreadConfigSnapshot) -> Thre
&config_snapshot.permission_profile,
config_snapshot.cwd.as_path(),
),
permission_profile: config_snapshot.permission_profile.clone().into(),
active_permission_profile: thread_response_active_permission_profile(
config_snapshot.active_permission_profile.clone(),
),
@@ -1501,7 +1500,6 @@ fn thread_settings_from_applied_event(
&thread_settings.permission_profile,
thread_settings.cwd.as_path(),
),
permission_profile: thread_settings.permission_profile.clone().into(),
active_permission_profile: thread_response_active_permission_profile(
thread_settings.active_permission_profile.clone(),
),
@@ -7,7 +7,6 @@ use app_test_support::to_response;
use app_test_support::write_mock_responses_config_toml;
use codex_app_server_protocol::JSONRPCError;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::PermissionProfile;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::SandboxPolicy;
use codex_app_server_protocol::ServerNotification;
@@ -21,10 +20,7 @@ use codex_app_server_protocol::TurnStartParams;
use codex_app_server_protocol::TurnStartResponse;
use codex_app_server_protocol::UserInput as V2UserInput;
use codex_features::Feature;
use codex_protocol::models::PermissionProfile as CorePermissionProfile;
use codex_protocol::openai_models::ReasoningEffort;
use codex_protocol::permissions::FileSystemAccessMode;
use codex_protocol::permissions::FileSystemPath;
use codex_utils_absolute_path::AbsolutePathBuf;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
@@ -110,31 +106,6 @@ async fn read_thread_settings_updated(
Ok(notification)
}
fn assert_permission_profile_write_root(
permission_profile: &PermissionProfile,
expected_root: &AbsolutePathBuf,
unexpected_root: &AbsolutePathBuf,
) {
let permission_profile: CorePermissionProfile = permission_profile.clone().into();
let sandbox_policy = permission_profile.file_system_sandbox_policy();
assert!(
sandbox_policy.entries.iter().any(|entry| {
entry.access == FileSystemAccessMode::Write
&& matches!(&entry.path, FileSystemPath::Path { path } if path == expected_root)
}),
"expected permission profile write entries to contain {expected_root:?}; got {:?}",
sandbox_policy.entries
);
assert!(
!sandbox_policy.entries.iter().any(|entry| {
entry.access == FileSystemAccessMode::Write
&& matches!(&entry.path, FileSystemPath::Path { path } if path == unexpected_root)
}),
"did not expect permission profile write entries to contain {unexpected_root:?}; got {:?}",
sandbox_policy.entries
);
}
#[tokio::test]
async fn thread_settings_update_applies_partial_patch_and_emits_full_state() -> Result<()> {
let server = create_mock_responses_server_repeating_assistant("Done").await;
@@ -205,7 +176,7 @@ async fn thread_settings_update_absolutizes_relative_cwd_before_permissions() ->
let response = send_thread_settings_update(
&mut mcp,
ThreadSettingsUpdateParams {
thread_id: thread.id,
thread_id: thread.id.clone(),
cwd: Some(next_cwd),
permissions: Some(":workspace".to_string()),
..Default::default()
@@ -214,10 +185,12 @@ async fn thread_settings_update_absolutizes_relative_cwd_before_permissions() ->
.await?;
assert_eq!(response.thread_settings.cwd, next_cwd_abs);
assert_permission_profile_write_root(
&response.thread_settings.permission_profile,
&next_cwd_abs,
&thread.cwd,
assert_eq!(
response
.thread_settings
.active_permission_profile
.map(|profile| profile.id),
Some(":workspace".to_string())
);
Ok(())
@@ -311,7 +284,7 @@ async fn thread_settings_update_waits_for_pending_cwd_before_permissions() -> Re
.await?;
let update_request_id = mcp
.send_thread_settings_update_request(ThreadSettingsUpdateParams {
thread_id: thread.id,
thread_id: thread.id.clone(),
permissions: Some(":workspace".to_string()),
..Default::default()
})
@@ -322,10 +295,12 @@ async fn thread_settings_update_waits_for_pending_cwd_before_permissions() -> Re
read_response::<ThreadSettingsUpdateResponse>(&mut mcp, update_request_id).await?;
assert_eq!(update_response.thread_settings.cwd, next_cwd_abs);
assert_permission_profile_write_root(
&update_response.thread_settings.permission_profile,
&next_cwd_abs,
&thread.cwd,
assert_eq!(
update_response
.thread_settings
.active_permission_profile
.map(|profile| profile.id),
Some(":workspace".to_string())
);
wait_for_turn_completed(&mut mcp).await?;