mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Scope Guardian subscriptions to live reviewers (#63357)
## Why Persisted channel subscriptions could route new evidence to an agent before its reviewer started. A replacement reviewer conversation for a still-loaded agent needs to retain the agent's subscriptions and replay its inbox. ## What changed Keep channel subscriptions and queued evidence references in the live reviewer's inbox. Replacement conversations reuse that inbox, and a reviewer that reloads after shutdown starts with an empty inbox and subscription set. Route committed evidence once per matching inbox, even when several channels match. Unsubscribing preserves evidence already selected for delivery, and closing an inbox prevents pending deliveries from reaching a later reviewer for the same agent. Manage subscriptions through the reviewer tools. An exact channel name can be subscribed to before the channel exists, and evidence remains searchable on the message board. ## Testing Cover pending delivery across unsubscribe and reviewer reload, and exercise subscription and delivery behavior with both in-memory and SQLite boards. GitOrigin-RevId: e3dfbcc7c3f34bd509faa24742cf83d9236ef83a
This commit is contained in:
@@ -22,6 +22,8 @@ use std::num::NonZeroU32;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
const MAX_CHANNEL_BYTES: usize = 128;
|
||||
|
||||
// Local and remote implementations must remain usable through the same handle.
|
||||
const _: Option<&dyn AgentMessageBoard> = None;
|
||||
|
||||
@@ -89,16 +91,6 @@ pub trait AgentMessageBoard: Send + Sync {
|
||||
request: AppendRequest,
|
||||
) -> BoxFuture<'_, Result<PostMetadata>>;
|
||||
|
||||
/// Like a silent append, also returns the subscribers at the moment of insertion.
|
||||
/// An idempotent retry returns the existing post and no new deliveries.
|
||||
fn append_with_subscribers(
|
||||
&self,
|
||||
_caller: ThreadId,
|
||||
_request: AppendRequest,
|
||||
) -> BoxFuture<'_, Result<(PostMetadata, Vec<ThreadId>)>> {
|
||||
unsupported("appending with subscribers")
|
||||
}
|
||||
|
||||
fn list_threads(
|
||||
&self,
|
||||
caller: ThreadId,
|
||||
@@ -142,15 +134,6 @@ pub trait AgentMessageBoard: Send + Sync {
|
||||
caller: ThreadId,
|
||||
request: SubscriptionRequest,
|
||||
) -> BoxFuture<'_, Result<SubscriptionState>>;
|
||||
|
||||
/// List a caller's current channel subscriptions on a live board.
|
||||
fn subscribed_channels(
|
||||
&self,
|
||||
_caller: ThreadId,
|
||||
_page: PageRequest,
|
||||
) -> BoxFuture<'_, Result<Page<String>>> {
|
||||
unsupported("listing channel subscriptions")
|
||||
}
|
||||
}
|
||||
|
||||
fn unsupported<T>(operation: &'static str) -> BoxFuture<'static, Result<T>> {
|
||||
@@ -184,6 +167,21 @@ pub enum SubscriptionChange {
|
||||
Unsubscribe,
|
||||
}
|
||||
|
||||
/// Checks whether a name is valid for channel creation, independent of board contents.
|
||||
pub fn validate_channel(name: &str) -> Result<()> {
|
||||
if name.is_empty()
|
||||
|| name.len() > MAX_CHANNEL_BYTES
|
||||
|| name.trim() != name
|
||||
|| name.chars().any(char::is_control)
|
||||
{
|
||||
return Err(CodexErr::InvalidRequest(
|
||||
"channel names must contain 1–128 bytes without edge whitespace or control characters"
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct CreateChannelRequest {
|
||||
pub channel_name: String,
|
||||
@@ -260,7 +258,6 @@ pub struct PostRequest {
|
||||
pub(crate) enum PostBehavior {
|
||||
Discussion,
|
||||
SilentAppend,
|
||||
SilentAppendWithSubscribers,
|
||||
}
|
||||
|
||||
/// Request to append evidence without subscribing its author or notifying anyone.
|
||||
|
||||
Reference in New Issue
Block a user