Skip to main content

LiminalConnectionNotifier

Struct LiminalConnectionNotifier 

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

Connection-keyed ConnectionNotifier that turns liminal’s in-band worker registration into a first-class ConnectedWorkerRegistry membership.

This is the SERVER half of LSUB-L2: when a worker connects with a WireWorkerRegistration (the SDK’s connect_with_registration), liminal’s connection process invokes on_worker_registered with the connection’s beamr pid and the worker’s declared (namespaces, task_queue, node, activity_types). The notifier builds a WorkerDelivery::Liminal over the connection and inserts it into the registry — the SAME registry entry, selected the SAME way, as a gRPC worker — retiring the LSUB-1 out-of-band active_connection_pids() + hard-coded registration hack.

§Lifetime of the registration guard

ConnectedWorkerRegistry::register_delivery returns a WorkerRegistration guard whose drop deregisters the worker. The notifier OWNS that guard keyed by pid (Mutex<HashMap<u64, WorkerRegistration>>), so the registration lives exactly as long as the connection: it is inserted on register and removed (dropped) on on_worker_unregistered, which liminal fires on connection close.

§Construction-order cycle (notifier <-> supervisor)

[Self::dispatch’s delivery] needs a ConnectionSupervisor handle to push to the worker’s connection, but the supervisor is itself constructed WITH this notifier (ConnectionSupervisor::with_services_and_notifier) — a cycle. The notifier therefore holds the supervisor behind a OnceLock, populated IMMEDIATELY after the supervisor is built via Self::bind_supervisor. The OnceLock is never read before it is set in correct wiring (a worker can only register after the listener — built after the supervisor and after bind_supervisor — accepts its connection); if it somehow were, registration is REJECTED with a typed error rather than panicking, so there is no production unwrap/expect and no second always-None code path.

Implementations§

Source§

impl LiminalConnectionNotifier

Source

pub fn new(registry: ConnectedWorkerRegistry) -> Self

Build a notifier that registers connecting workers into registry.

The supervisor handle is bound separately via Self::bind_supervisor immediately after the supervisor is constructed, resolving the notifier <-> supervisor construction cycle (see the type docs).

Source

pub fn with_heartbeat_tracker(self, tracker: HeartbeatTracker) -> Self

Install the shared per-task liveness tracker so a worker’s automatic WorkerLivenessBeat publishes refresh the SAME in-flight entries the bridge dispatcher tracks and the #176 sweeper expires.

MUST be wired on every boot that hosts the engine-seam bridge (the production composition does), or the sweeper would expire healthy liminal workers running activities longer than the heartbeat window. Without it (isolated tests that never bridge-dispatch) beats are consumed and dropped.

Source

pub fn with_transcript_publisher( self, publisher: ActivityEventPublisher, ) -> Self

Install the transcript sequencer a worker’s observability publishes drain into (NOI-5b), capturing the CURRENT Tokio runtime handle to bridge the synchronous connection-process callback onto the async publish.

MUST be called from within a Tokio runtime (the server boot path is), so the captured Handle can spawn the append+fan-out when a worker publishes a transcript event over the reserved channel. Without this builder the observability tap is a no-op (a plain, non-agent deployment).

§Panics

Panics if called outside a Tokio runtime — a construction-time wiring error in the server boot, never a runtime condition (the boot path always builds the notifier inside the server runtime).

Source

pub fn with_intervention_capabilities( self, capabilities: InterventionCapabilities, ) -> Self

Set the neutral intervention capability set every worker registering through this notifier advertises (NOI-6, item 4).

The composition root wires this from the harness’s advertised AgentSession::capabilities() so a liminal-connected agent worker’s handle carries the primitives its harness supports, which the intervention router gates on. Without this builder the set is empty (observability-only), so a plain activity worker advertises no controls. Pure builder addition, mirroring the registry’s capability-carrying registration façade.

Source

pub fn bind_supervisor(&self, supervisor: ConnectionSupervisor) -> bool

Bind the connection supervisor the notifier pushes through, immediately after it is constructed with this notifier.

Returns true when the supervisor was stored, false when it was already bound (a second bind is a wiring bug and is ignored, never overwriting the live handle). Call this exactly once, right after ConnectionSupervisor::with_services_and_notifier.

Trait Implementations§

Source§

impl ConnectionNotifier for LiminalConnectionNotifier

Source§

fn on_worker_registered( &self, pid: u64, registration: &WireWorkerRegistration, ) -> Result<(), LiminalServerError>

Called when a worker registers on the connection identified by pid. Read more
Source§

fn on_worker_unregistered(&self, pid: u64)

Called when the connection identified by pid — which had a stored registration — closes, so the application can release the association. Read more
Source§

fn on_channel_publish(&self, pid: u64, channel: &str, payload: &[u8]) -> bool

Called when the connection identified by pid publishes to channel, carrying the opaque envelope payload, BEFORE the normal channel fan-out. Read more
Source§

impl Debug for LiminalConnectionNotifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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