fix(runtime): isolate agent state by project (#101)

This commit is contained in:
2026-07-25 22:14:02 +02:00
parent 6a87c4635f
commit 6e98fd89f7
52 changed files with 1894 additions and 805 deletions

View File

@ -7,7 +7,7 @@
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::ids::{AgentId, TaskId};
use crate::ids::{AgentId, RuntimeAgentKey, TaskId};
use crate::mailbox::TicketId;
/// Default bounded inbox capacity per agent.
@ -114,6 +114,8 @@ pub struct InboxReceipt {
pub item_id: TicketId,
/// Target agent.
pub agent_id: AgentId,
/// Runtime-scoped target agent.
pub runtime_key: RuntimeAgentKey,
/// FIFO depth after the operation.
pub depth: usize,
/// Enqueue outcome.
@ -126,6 +128,8 @@ pub struct InboxReceipt {
pub struct AgentInboxSnapshot {
/// Target agent.
pub agent_id: AgentId,
/// Runtime-scoped target agent.
pub runtime_key: RuntimeAgentKey,
/// Number of queued inbox items.
pub depth: usize,
/// FIFO-ordered items.
@ -162,11 +166,15 @@ pub trait AgentInbox: Send + Sync {
///
/// # Errors
/// [`InboxError`] when the item is invalid or a normal message overflows.
fn enqueue_message(&self, agent: AgentId, item: InboxItem) -> Result<InboxReceipt, InboxError>;
fn enqueue_message(
&self,
agent: RuntimeAgentKey,
item: InboxItem,
) -> Result<InboxReceipt, InboxError>;
/// Pops the next queued inbox item, if any.
fn dequeue_next(&self, agent: AgentId) -> Option<InboxItem>;
fn dequeue_next(&self, agent: RuntimeAgentKey) -> Option<InboxItem>;
/// Returns the FIFO snapshot for `agent`.
fn snapshot(&self, agent: AgentId) -> AgentInboxSnapshot;
fn snapshot(&self, agent: RuntimeAgentKey) -> AgentInboxSnapshot;
}