//! The native memories were removed: `memory/reset` and `memory/status` stay in the protocol //! for compatibility with older clients, but reset is refused and deletes nothing. use akode_app_server_protocol::MemoryStatusResponse; use akode_app_server_protocol::RequestId; use anyhow::Result; use app_test_support::MockResponsesConfig; use app_test_support::TestAppServer; use pretty_assertions::assert_eq; use tempfile::TempDir; use tokio::time::timeout; const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); #[tokio::test] async fn memory_reset_is_unsupported_and_deletes_nothing() -> Result<()> { let codex_home = TempDir::new()?; MockResponsesConfig::new("http://127.0.0.1:9").write(codex_home.path())?; for directory in ["memories", "memories_v2"] { let root = codex_home.path().join(directory); tokio::fs::create_dir_all(root.join("rollout_summaries")).await?; tokio::fs::write(root.join("memory_summary.md"), "v1\nold memory\n").await?; } tokio::fs::write(codex_home.path().join("memories_1.sqlite"), b"not opened").await?; let mut mcp = TestAppServer::builder() .with_codex_home(codex_home.path()) .without_auto_env() .build_initialized_with_timeout(DEFAULT_READ_TIMEOUT) .await?; let request_id = mcp .send_raw_request("memory/reset", /*params*/ None) .await?; let error = timeout( DEFAULT_READ_TIMEOUT, mcp.read_stream_until_error_message(RequestId::Integer(request_id)), ) .await??; assert!( error.error.message.contains("non supportato"), "{}", error.error.message ); for directory in ["memories", "memories_v2"] { assert!( codex_home .path() .join(directory) .join("memory_summary.md") .exists() ); } assert_eq!( tokio::fs::read(codex_home.path().join("memories_1.sqlite")).await?, b"not opened" ); Ok(()) } #[tokio::test] async fn memory_status_is_never_ready() -> Result<()> { let codex_home = TempDir::new()?; MockResponsesConfig::new("http://127.0.0.1:9").write(codex_home.path())?; let mut mcp = TestAppServer::builder() .with_codex_home(codex_home.path()) .without_auto_env() .build_initialized_with_timeout(DEFAULT_READ_TIMEOUT) .await?; let request_id = mcp .send_raw_request( "memory/status", Some(serde_json::json!({ "minConsolidatedThreads": 1 })), ) .await?; let status: MemoryStatusResponse = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(request_id)).await??; assert_eq!( status, MemoryStatusResponse { v2_consolidated_threads: 0, v2_ready: false, } ); Ok(()) }