mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
## What changed - Change `ReviewDecision::Denied` to carry a rejection string and update the generated protocol schemas. - Preserve specific rejection reasons through command, patch, network, MCP, delegated, and automatic approval flows so tool results can return them to the model. - Distinguish invalid approval responses from user declines and truncate oversized rejection messages before adding them to model context. ## Testing - Add coverage for denial serialization, invalid app-server approval responses, dropped automatic reviews, network rejection propagation, and rejection-message truncation. GitOrigin-RevId: d48a55643aa03c7ecfa08a8e4b669913eec5464a
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
use super::*;
|
|
use codex_protocol::approvals::NetworkPolicyAmendment;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn approval_resolution_rejects_denied_network_policy_amendment() {
|
|
let resolution = ApprovalResolution {
|
|
decision: ReviewDecision::NetworkPolicyAmendment {
|
|
network_policy_amendment: NetworkPolicyAmendment {
|
|
host: "denied.example.com".to_string(),
|
|
action: NetworkPolicyRuleAction::Deny,
|
|
},
|
|
},
|
|
source: ApprovalResolutionSource::User,
|
|
};
|
|
assert!(matches!(
|
|
resolution.into_tool_result(),
|
|
Err(ToolError::Rejected(rejection)) if rejection == "rejected by user"
|
|
));
|
|
}
|
|
|
|
#[test]
|
|
fn guardian_cwd_preserves_drive_shaped_local_posix_path() {
|
|
let native_cwd = AbsolutePathBuf::try_from(std::path::PathBuf::from("/C:/workspace"))
|
|
.expect("drive-shaped POSIX path should be absolute");
|
|
let cwd = PathUri::from_abs_path(&native_cwd);
|
|
|
|
assert_eq!(
|
|
guardian_cwd(codex_exec_server::LOCAL_ENVIRONMENT_ID, cwd)
|
|
.expect("local cwd should retain the host path convention"),
|
|
native_cwd
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn guardian_cwd_rejects_foreign_remote_path() {
|
|
let cwd = PathUri::parse("file:///C:/workspace").expect("valid Windows path URI");
|
|
|
|
assert!(guardian_cwd(codex_exec_server::REMOTE_ENVIRONMENT_ID, cwd).is_err());
|
|
}
|