diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json index fbc774ebaf..8f862153c8 100644 --- a/codex-rs/core/config.schema.json +++ b/codex-rs/core/config.schema.json @@ -577,9 +577,9 @@ "FileSystemAccessMode": { "description": "Access mode for a filesystem entry.\n\nWhen two equally specific entries target the same path, we compare these by conflict precedence rather than by capability breadth: `none` beats `write`, and `write` beats `read`.", "enum": [ - "none", "read", - "write" + "write", + "none" ], "type": "string" }, diff --git a/codex-rs/protocol/src/permissions.rs b/codex-rs/protocol/src/permissions.rs index a5c06c9896..6c2e7d336f 100644 --- a/codex-rs/protocol/src/permissions.rs +++ b/codex-rs/protocol/src/permissions.rs @@ -1,4 +1,3 @@ -use std::cmp::Ordering; use std::collections::HashSet; use std::ffi::OsStr; use std::io; @@ -40,24 +39,29 @@ impl NetworkSandboxPolicy { /// When two equally specific entries target the same path, we compare these by /// conflict precedence rather than by capability breadth: `none` beats /// `write`, and `write` beats `read`. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, JsonSchema, TS)] +#[derive( + Debug, + Clone, + Copy, + PartialEq, + Eq, + PartialOrd, + Ord, + Serialize, + Deserialize, + Display, + JsonSchema, + TS, +)] #[serde(rename_all = "lowercase")] #[strum(serialize_all = "lowercase")] pub enum FileSystemAccessMode { - None, Read, Write, + None, } impl FileSystemAccessMode { - fn precedence_rank(self) -> u8 { - match self { - FileSystemAccessMode::Read => 0, - FileSystemAccessMode::Write => 1, - FileSystemAccessMode::None => 2, - } - } - pub fn can_read(self) -> bool { !matches!(self, FileSystemAccessMode::None) } @@ -67,18 +71,6 @@ impl FileSystemAccessMode { } } -impl PartialOrd for FileSystemAccessMode { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for FileSystemAccessMode { - fn cmp(&self, other: &Self) -> Ordering { - self.precedence_rank().cmp(&other.precedence_rank()) - } -} - #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, TS)] #[serde(tag = "kind", rename_all = "snake_case")] #[ts(tag = "kind")]