Module global_context

Module global_context 

Source
Expand description

Process-global context, root client actor, and supervision bridge.

This module provides the Rust equivalent of Python’s context(), this_host(), and this_proc(). A singleton Host is lazily created with the GlobalClientActor on its local_proc:

let cx = context().await;
cx.actor_instance    // c.f. Python: context().actor_instance
this_host().await    // c.f. Python: this_host()
this_proc().await    // c.f Python: this_proc()

§Undeliverables → supervision

When the runtime detects that a message cannot be delivered, it produces an Undeliverable<MessageEnvelope>. The global root client observes these failures, converts them into ActorSupervisionEvents, and forwards them to the currently active mesh supervision sink.

GC-1 (undeliverable routing): Any Undeliverable<MessageEnvelope> observed by the global root client must be reported as an ActorSupervisionEvent to the active ProcMesh, and handling that failure must never crash the global client. The root client acts as a monitor, not a participant: routing failures are treated as signals to be reported, not fatal errors.

§Multiple ProcMeshes

A process may allocate more than one ProcMesh (e.g. internal/controller meshes plus an application mesh). The root client is a process-wide singleton, so its supervision sink is also process-global.

The active mesh is defined using last-sink-wins semantics: each newly allocated ProcMesh installs its sink, overriding the previous one.

If no sink has been installed yet (early/late binding), undeliverables are logged and dropped, preserving forward progress until a mesh becomes available.

Structs§

GlobalClientActor
Process-global “root client” actor.
GlobalContext
Process-global Monarch context for Rust programs. Symmetric with Python’s context().

Functions§

context
Returns the process-global Monarch context, lazily initialized.
register_client_host
Register the client host mesh from an external runtime (Python). Called by Python’s bootstrap_host() so that try_this_host() can discover C for the A/C invariant.
this_host
Returns the singleton HostMesh c.f. Python’s this_host().
this_proc
Returns the local ProcMesh c.f Python’s this_proc().
try_this_host
Returns the client host mesh if available, without triggering lazy bootstrap. Checks both the Rust global context and the external registration (Python). Used by MeshAdminAgent to discover C at query time (A/C invariant).