mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
## Why Older executors sandbox reads whenever a policy is supplied, even when the policy allows unrestricted reads. This can interfere with loading skills across executor versions. ## What changed - Omit sandbox contexts from remote read operations when reads are unrestricted and explicit permission paths are valid for the target path convention. Retain contexts that require executor-side path validation. - Check remote `windows_mxc` support before sending MXC sandbox contexts for reads or capability discovery, returning an update-executor error when unsupported. ## Testing Add coverage for permission path validation across read operations, unsupported MXC requests, and skill loading over Noise with mismatched app and executor versions, including selected skill roots with capability discovery disabled. GitOrigin-RevId: 4a2a7ccaa2ba4daac657bd84aea603404452be45
63 lines
2.5 KiB
Rust
63 lines
2.5 KiB
Rust
//! Acquires executor inventories without activation and replays safe reads after recovery.
|
|
|
|
use super::Environment;
|
|
use crate::DiscoverV2CapabilitiesRequest;
|
|
use crate::DiscoverV2CapabilitiesResponse;
|
|
use crate::EnvironmentInfo;
|
|
use crate::ExecServerError;
|
|
use codex_build_info::BuildInfo;
|
|
|
|
/// The final DiscoveryV2 contract starts at stable 0.164.0.
|
|
pub fn supports_capability_discovery_v2(info: &EnvironmentInfo) -> bool {
|
|
let build = BuildInfo::from_version(&info.executor_version);
|
|
let minimum = BuildInfo::from_version("0.164.0");
|
|
info.capabilities.capability_discovery_v2 && build.version() >= minimum.version()
|
|
}
|
|
|
|
impl Environment {
|
|
/// Identifies the initialized executor session; transport recovery preserves this ID.
|
|
pub(crate) async fn executor_session_id(&self) -> Result<Option<String>, ExecServerError> {
|
|
match &self.remote_client {
|
|
Some(client) => Ok(client.get().await?.session_id()),
|
|
None => Ok(None),
|
|
}
|
|
}
|
|
|
|
/// Returns metadata for the caller's cwd from the remote session's V2 lifecycle.
|
|
/// Local environments and older executors retain the V1 selected-root API.
|
|
pub async fn discover_capabilities_v2(
|
|
&self,
|
|
params: DiscoverV2CapabilitiesRequest,
|
|
) -> Result<DiscoverV2CapabilitiesResponse, ExecServerError> {
|
|
let Some(client) = &self.remote_client else {
|
|
return Err(ExecServerError::Protocol(
|
|
"capabilities/discoverV2 requires a remote environment".to_string(),
|
|
));
|
|
};
|
|
let connection_state = client.subscribe_connection_state();
|
|
let client = client.get().await?;
|
|
let discover = || async {
|
|
let info = client.environment_info().await?;
|
|
if !supports_capability_discovery_v2(&info) {
|
|
return Err(ExecServerError::Protocol(
|
|
"capabilities/discoverV2 is unavailable in this environment session"
|
|
.to_string(),
|
|
));
|
|
}
|
|
if params.sandbox.as_ref().is_some_and(|sandbox| {
|
|
sandbox.windows_sandbox_selection == crate::WindowsSandboxSelection::Mxc
|
|
}) {
|
|
crate::sandbox_selection::validate_remote_mxc(&info)
|
|
.map_err(|error| ExecServerError::Protocol(error.to_string()))?;
|
|
}
|
|
client.discover_capabilities_v2(params.clone()).await
|
|
};
|
|
self.discover_with_recovery(connection_state, discover)
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "discovery_v2_tests.rs"]
|
|
mod tests;
|