Skip to main content

WorldHost

Struct WorldHost 

Source
pub struct WorldHost { /* private fields */ }
Expand description

Owns the world and the run-id map; drives the world and services control ops.

Implementations§

Source§

impl WorldHost

Source

pub fn new(world: PipelineWorld) -> Self

Wrap a world with a fresh interaction hub.

Source

pub fn with_interactions( world: PipelineWorld, interactions: InteractionHub, ) -> Self

Wrap a world with a specific interaction hub - the daemon shares one hub between the tool service’s per-agent backends and this host.

Source

pub fn subagent_sender(&self) -> UnboundedSender<SubAgentOp>

A sender for SubAgentOps. The daemon hands a clone to each agent’s tool state so the sub-agent tools can reach the world through the host.

Source

pub fn subscribe(&self) -> Receiver<WorldEvent>

Subscribe to WorldEvents. The HTTP/WS gateway uses this (via the control transport’s Subscribe) to push updates instead of polling.

Source

pub fn event_sender(&self) -> Sender<WorldEvent>

The world-event sender, handed to the control transport so a Subscribe connection can stream events.

Source

pub fn set_spawner(&mut self, spawner: Spawner)

Install the spawner used to service Spawn control ops. Without one, a Spawn op replies with an error.

Source

pub fn set_spawn_preprocessor(&mut self, pp: SpawnPreprocessor)

Install the async hook awaited before each top-level Spawn (see SpawnPreprocessor).

Source

pub fn set_reloader(&mut self, reloader: Reloader)

Install the reloader used to page an unloaded run back in on demand. Without one, an op targeting a run that isn’t in memory just misses.

Source

pub fn set_force_terminator(&mut self, force_terminator: ForceTerminator)

Install the ForceTerminator used to terminate a run on disk when the world cannot hold it. Without one, a cancel that misses in the world and can’t be reloaded just misses.

Source

pub fn set_reaper(&mut self, reaper: Reaper)

Install the reap hook run just before each terminal agent is despawned, so the daemon can tear down that agent’s sandbox and drop its tool state. Without one, reaping just despawns the entity (the prior behavior).

Source

pub fn interactions(&self) -> InteractionHub

A clone of the interaction hub, for building per-agent backends.

Source

pub fn world_mut(&mut self) -> &mut PipelineWorld

Mutable access to the underlying world (for the spawner to add agents).

Source

pub fn register(&mut self, run_id: impl Into<String>, entity: Entity)

Record the run-id → entity mapping for a freshly-spawned agent.

Source

pub fn handle(&mut self, op: ControlOp)

Apply one control op and reply on its channel. A dropped reply receiver is harmless (the requester went away).

Source

pub async fn flush_and_stop(&mut self)

Flush all queued persistence and stop the hosted world, guaranteeing every dirty agent’s final snapshot reaches disk (see PipelineWorld::flush_and_stop). Invoked automatically when Self::serve returns; also exposed directly for callers that drive the world themselves.

Source

pub async fn serve(&mut self, control_rx: UnboundedReceiver<ControlOp>)

Run the host: drive the world to quiescence, then park until an async result wakes it, a control op arrives, or shutdown is signalled. Returns when shutdown fires or the control channel closes - and before returning, flushes all queued persistence to disk (Self::flush_and_stop) so a clean daemon shutdown never loses a dirty agent’s final snapshot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more