Bind selected capability roots to model steps

This commit is contained in:
jif-oai
2026-06-25 11:31:28 +01:00
parent d339c18645
commit cfa422c672
10 changed files with 144 additions and 0 deletions
+2
View File
@@ -22,6 +22,7 @@ mod relay_proto;
mod remote;
mod remote_file_system;
mod remote_process;
mod resolved_capability;
mod rpc;
mod runtime_paths;
mod sandboxed_file_system;
@@ -143,6 +144,7 @@ pub use protocol::WriteResponse;
pub use protocol::WriteStatus;
pub use remote::RemoteEnvironmentConfig;
pub use remote::run_remote_environment;
pub use resolved_capability::ResolvedSelectedCapabilityRoot;
pub use runtime_paths::ExecServerRuntimePaths;
pub use server::DEFAULT_LISTEN_URL;
pub use server::ExecServerListenUrlParseError;
@@ -0,0 +1,47 @@
use std::fmt;
use std::sync::Arc;
use codex_protocol::capabilities::SelectedCapabilityRoot;
use crate::Environment;
use crate::ExecutorFileSystem;
/// A selected capability root pinned to the exact environment instance that owns it.
///
/// This value is process-local and must not be persisted. Cloning it keeps the same
/// [`Environment`] alive so every consumer of one model step uses the same executor.
#[derive(Clone)]
pub struct ResolvedSelectedCapabilityRoot {
selected_root: SelectedCapabilityRoot,
environment: Arc<Environment>,
}
impl ResolvedSelectedCapabilityRoot {
pub fn new(selected_root: SelectedCapabilityRoot, environment: Arc<Environment>) -> Self {
Self {
selected_root,
environment,
}
}
pub fn selected_root(&self) -> &SelectedCapabilityRoot {
&self.selected_root
}
pub fn environment(&self) -> &Arc<Environment> {
&self.environment
}
pub fn file_system(&self) -> Arc<dyn ExecutorFileSystem> {
self.environment.get_filesystem()
}
}
impl fmt::Debug for ResolvedSelectedCapabilityRoot {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("ResolvedSelectedCapabilityRoot")
.field("selected_root", &self.selected_root)
.finish_non_exhaustive()
}
}