Add exec-server network policy callback types (#34620)

## What changed

- Define the `network/policyRequest` RPC payloads for associating a network request with a process and returning an `allow`, `deny`, or `ask` decision.
- Cover HTTP, HTTPS CONNECT, and SOCKS5 TCP/UDP requests, with shared size limits for callback fields.
- Add the backward-compatible `requestPolicyDecisions` remote proxy option so executors can opt in to sending policy decisions to clients.
- Re-export the new protocol types from `codex-exec-server`.

## Testing

- Verify the request and decision JSON shapes.
- Verify that the proxy opt-in is omitted and defaults to `false` for legacy configurations, while an enabled value round-trips.

GitOrigin-RevId: 65b0a0723d1abb6e4f504a41d3a0dd41f5f21bf7
This commit is contained in:
viyatb-oai
2026-07-21 21:54:31 +00:00
committed by copyberry
parent ad020f29ae
commit d838ea0f64
6 changed files with 160 additions and 0 deletions
@@ -66,6 +66,9 @@ pub struct RemoteNetworkProxyConfig {
pub domains: Option<NetworkDomainPermissions>,
pub unix_sockets: Option<NetworkUnixSocketPermissions>,
pub allow_local_binding: bool,
/// Whether the executor sends domain policy decisions back to the client.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_policy_decisions: bool,
}
impl RemoteNetworkProxyConfig {
@@ -88,6 +91,7 @@ impl RemoteNetworkProxyConfig {
domains: config.domains.clone(),
unix_sockets: config.unix_sockets.clone(),
allow_local_binding: config.allow_local_binding,
request_policy_decisions: false,
})
}
@@ -118,3 +118,26 @@ fn launch_config_materializes_audit_and_execution_attribution() {
assert_eq!(state.environment_id(), Some("remote"));
assert_eq!(state.execution_id().as_deref(), Some("execution-1"));
}
#[test]
fn policy_decision_callback_opt_in_is_backward_compatible() {
let mut config =
RemoteNetworkProxyConfig::from_effective_config(&NetworkProxyConfig::default())
.expect("supported remote config");
let legacy = serde_json::to_value(&config).expect("serialize legacy config");
assert_eq!(legacy.get("requestPolicyDecisions"), None);
assert!(
!serde_json::from_value::<RemoteNetworkProxyConfig>(legacy)
.expect("deserialize legacy remote config")
.request_policy_decisions
);
config.request_policy_decisions = true;
let enabled = serde_json::to_value(&config).expect("serialize callback-enabled config");
assert_eq!(enabled["requestPolicyDecisions"], true);
assert_eq!(
serde_json::from_value::<RemoteNetworkProxyConfig>(enabled)
.expect("deserialize callback-enabled config"),
config
);
}