Files
codex/codex-rs/message-board/src/in_memory_tests.rs
T
felixxia-oai a47d1338c1 Extract shared message-board code into codex-message-board (#55970)
## What changed

Move the message-board API, types, permissions, storage backends, and tool implementations into the new `codex-message-board` crate. Keep extension registration in `codex-agent-message-board-extension`, and update core and the remote client to use the shared crate directly.

Move the existing board tests with the implementation and add the crate to the Cargo workspace and Bazel build.

GitOrigin-RevId: 33ce527c2bef7f862eba55cb9b32222902ccf4ad
2026-10-21 19:34:51 +00:00

67 lines
1.9 KiB
Rust

//! Verifies that registry cleanup releases expired entries and preserves live boards.
use super::*;
use crate::NotificationDelivery;
use futures::future::BoxFuture;
use pretty_assertions::assert_eq;
struct UnusedHost;
impl MessageBoardHost for UnusedHost {
fn agent_path(&self, _caller: ThreadId) -> BoxFuture<'_, Result<AgentPath>> {
unreachable!("registry tests do not invoke host capabilities")
}
fn resolve_agent(&self, _path: AgentPath) -> BoxFuture<'_, Result<ThreadId>> {
unreachable!("registry tests do not invoke host capabilities")
}
fn current_time(&self, _caller: ThreadId) -> BoxFuture<'_, Result<DateTime<Utc>>> {
unreachable!("registry tests do not invoke host capabilities")
}
fn notify(
&self,
_recipient: ThreadId,
_post: PostPreview,
) -> BoxFuture<'_, Result<NotificationDelivery>> {
unreachable!("registry tests do not invoke host capabilities")
}
}
#[tokio::test]
async fn opening_boards_prunes_expired_entries_and_preserves_live_state() {
let boards = InMemoryMessageBoards::default();
let identity = SessionId::new();
let live = boards.open(identity, Arc::new(UnusedHost)).await;
for _ in 0..16 {
let next_identity = SessionId::new();
let next = boards.open(next_identity, Arc::new(UnusedHost)).await;
assert_eq!(
boards
.states
.lock()
.await
.keys()
.copied()
.collect::<HashSet<_>>(),
HashSet::from([identity, next_identity]),
);
drop(next);
}
let shared = boards.open(identity, Arc::new(UnusedHost)).await;
assert!(Arc::ptr_eq(&live.state, &shared.state));
assert_eq!(
boards
.states
.lock()
.await
.keys()
.copied()
.collect::<HashSet<_>>(),
HashSet::from([identity]),
);
}