Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Rebind memory consolidation workspace roots (#32197)

jif601b61a83ffe
diff --git a/codex-rs/memories/write/src/phase2.rs b/codex-rs/memories/write/src/phase2.rs
index 1c7f35b5ae..a4464d29dc 100644
--- a/codex-rs/memories/write/src/phase2.rs
+++ b/codex-rs/memories/write/src/phase2.rs
@@ -332,8 +332,7 @@ mod agent {
exclude_slash_tmp: true,
};
agent_config
- .permissions
- .set_legacy_sandbox_policy(consolidation_sandbox_policy, agent_config.cwd.as_path())
+ .set_legacy_sandbox_policy(consolidation_sandbox_policy)
.ok()?;
agent_config.model = Some(
@@ -534,6 +533,10 @@ mod agent {
}
}
+#[cfg(test)]
+#[path = "phase2_workspace_roots_tests.rs"]
+mod workspace_roots_tests;
+
pub(super) fn get_watermark(
claimed_watermark: i64,
latest_memories: &[codex_state::Stage1Output],
diff --git a/codex-rs/memories/write/src/phase2_workspace_roots_tests.rs b/codex-rs/memories/write/src/phase2_workspace_roots_tests.rs
new file mode 100644
index 0000000000..ffaca77767
--- /dev/null
+++ b/codex-rs/memories/write/src/phase2_workspace_roots_tests.rs
@@ -0,0 +1,42 @@
+use super::agent;
+use crate::memory_root;
+use codex_model_provider::create_model_provider;
+use codex_protocol::protocol::SandboxPolicy;
+use core_test_support::responses::start_mock_server;
+use core_test_support::test_codex::test_codex;
+use pretty_assertions::assert_eq;
+use std::sync::Arc;
+use tempfile::TempDir;
+
+#[tokio::test]
+async fn consolidation_rebinds_workspace_roots_to_memory_root() -> anyhow::Result<()> {
+ let server = start_mock_server().await;
+ let home = Arc::new(TempDir::new()?);
+ let test = test_codex()
+ .with_home(home)
+ .build_with_auto_env(&server)
+ .await?;
+ let provider = create_model_provider(
+ test.config.model_provider.clone(),
+ Some(test.thread_manager.auth_manager()),
+ );
+
+ let agent_config =
+ agent::get_config(&test.config, provider.as_ref()).expect("agent config should be created");
+ let root = memory_root(&test.config.codex_home);
+
+ assert_eq!(agent_config.cwd, root);
+ assert_eq!(agent_config.workspace_roots, vec![root]);
+ assert_eq!(
+ agent_config.legacy_sandbox_policy(),
+ SandboxPolicy::WorkspaceWrite {
+ writable_roots: Vec::new(),
+ network_access: false,
+ exclude_tmpdir_env_var: true,
+ exclude_slash_tmp: true,
+ }
+ );
+
+ test.codex.shutdown_and_wait().await?;
+ Ok(())
+}