mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Make Code Mode wrappers transparent to Guardian model policies (#45915)
## Why Code Mode wrappers should preserve cached scores for nested actions so adaptive review can reuse them across cells. ## What changed Remove `code_mode` from `GuardianModelPolicy` and its approval scopes. Skip scoring and cache invalidation for direct Code Mode `exec` wrappers under model policies, leaving nested tools governed by their own categories. Preserve legacy wrapper scoring behavior. ## Testing Expand app-server coverage for score reuse across cells, synchronous nested reviews, required model policies, and legacy configurations. Retain checks that ordinary tools named `exec` or MCP tools named `wait` invalidate cached scores. GitOrigin-RevId: 7a0692e5330f3d4b4bda988ecbe7061bc8b2318c
This commit is contained in:
1 parent
2aff7208fe
commit
8f38d5a877
7 files changed
+112
-50
No files matched your search
@@ -403,7 +403,7 @@ const fn is_true(value: &bool) -> bool {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
||||
pub struct ModelInfo {
|
||||
/// Model-owned approval coverage. Absent preserves legacy settings; an empty map disables
|
||||
/// ordinary Guardian review. Keys are computer_use, shell, code_mode, file_changes, mcp, network,
|
||||
/// ordinary Guardian review. Keys are computer_use, shell, file_changes, mcp, network,
|
||||
/// and permissions. This does not override mandatory safety or administrator requirements.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub guardian: Option<GuardianModelPolicy>,
|
||||
|
||||
@@ -24,6 +24,7 @@ pub enum GuardianReviewMode {
|
||||
}
|
||||
|
||||
/// A complete model policy. Omitted scopes are disabled; unknown fields are ignored.
|
||||
/// Code Mode wrappers have no approval scope; their nested tools follow this policy.
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
||||
pub struct GuardianModelPolicy {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -31,8 +32,6 @@ pub struct GuardianModelPolicy {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub shell: Option<GuardianReviewMode>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub code_mode: Option<GuardianReviewMode>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub file_changes: Option<GuardianReviewMode>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub mcp: Option<GuardianReviewMode>,
|
||||
@@ -47,7 +46,6 @@ impl GuardianModelPolicy {
|
||||
match scope {
|
||||
GuardianScope::ComputerUse => self.computer_use,
|
||||
GuardianScope::Shell => self.shell,
|
||||
GuardianScope::CodeMode => self.code_mode,
|
||||
GuardianScope::FileChanges => self.file_changes,
|
||||
GuardianScope::Mcp => self.mcp,
|
||||
GuardianScope::Network => self.network,
|
||||
@@ -62,7 +60,6 @@ impl GuardianModelPolicy {
|
||||
pub enum GuardianScope {
|
||||
ComputerUse,
|
||||
Shell,
|
||||
CodeMode,
|
||||
FileChanges,
|
||||
Mcp,
|
||||
Network,
|
||||
@@ -97,7 +94,6 @@ impl GuardianScope {
|
||||
"shell" | "shell_command" | "exec_command" | "write_stdin" | "execve" => {
|
||||
Some(Self::Shell)
|
||||
}
|
||||
"exec" | "wait" => Some(Self::CodeMode),
|
||||
"apply_patch" => Some(Self::FileChanges),
|
||||
"request_permissions" => Some(Self::Permissions),
|
||||
_ => None,
|
||||
|
||||
@@ -16,7 +16,7 @@ fn guardian_policy_is_optional_and_tolerates_future_config() -> anyhow::Result<(
|
||||
|
||||
wire["guardian"] = serde_json::json!({
|
||||
"computer_use": "adaptive", "shell": "future_mode", "future_scope": {"version": 2},
|
||||
"mcp": null, "code_mode": "adaptive",
|
||||
"mcp": null, "permissions": "adaptive",
|
||||
});
|
||||
let model: ModelInfo = serde_json::from_value(wire)?;
|
||||
assert_eq!(
|
||||
@@ -24,7 +24,7 @@ fn guardian_policy_is_optional_and_tolerates_future_config() -> anyhow::Result<(
|
||||
Some(GuardianModelPolicy {
|
||||
computer_use: Some(GuardianReviewMode::Adaptive),
|
||||
shell: Some(GuardianReviewMode::Unknown),
|
||||
code_mode: Some(GuardianReviewMode::Adaptive),
|
||||
permissions: Some(GuardianReviewMode::Adaptive),
|
||||
..Default::default()
|
||||
})
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user