Builder paths
For new hosts, build from a mob definition.definition_path loads TOML, while
definition accepts an already parsed MobDefinition:
definition(...) or
definition_path(...) is required. The other common fields have defaults:
The older
mob_spec(...) path accepts a pre-built MobBootstrapSpec. It still
requires explicit module configuration and timeout because the spec already
owns its session service and construction policy:
mob_spec is present, the builder returns
MissingRequiredField(MobSpec). On the legacy path, omitting
module_config or timeout returns the corresponding missing-field error.
Bootstrap sequence
1
Mob bootstrap
The Meerkat mob runtime starts first. Members are provisioned, wiring is established, and the mob reaches an operational state. If this fails, the builder returns
UnifiedRuntimeBootstrapError::Mob.2
Module startup
The supervisor attempts each discovered module and records its startup transitions. A module that exhausts its restart policy remains unloaded and emits a supervisor warning. A module-runtime initialization error or startup-thread panic rolls back the already-started mob before the builder returns an error.
3
Event merging
Agent and module events feed the unified event transport. Hosts read the public snapshot and subscription APIs rather than accessing the internal event vector.
Rollback on failure
If module-runtime initialization fails or its startup thread panics after the mob has already started, the runtime performs a coordinated rollback:- Attempt to shut down the mob runtime
- If rollback succeeds, return the original module startup error
- If rollback also fails, return
ModuleStartupRollbackFailedcontaining both errors
Runtime handle
After successful bootstrap, the builder returns aUnifiedRuntime handle with access to:
The raw
MobkitRuntimeHandle is intentionally not exposed. Module operations
such as routing, delivery, memory, and gating are methods on UnifiedRuntime.
Reconciliation
The reconciliation method depends on which authority model built the runtime. For a classic runtime without identity-first authority, pass the complete desired member specs:desired_specs is a Vec<SpawnMemberSpec>. This path reconciles members,
managed peer edges, and delivery routing. When the router module is loaded,
it maintains route keys named mob.member.{member_id} with the
notification channel.
For an identity-first runtime, roster and topology providers own desired state.
Refresh those providers through the identity authority instead:
refresh_desired_topology returns Some(RestoreFlowResult) when identity-first
authority is attached and None otherwise. Calling whole-mob reconcile on an
identity-first runtime fails rather than bypassing that authority.
Shutdown
In the mob/module teardown sequence, graceful shutdown quiesces and stops the mob while its router and module dependencies remain alive. It then closes the event router and shuts down the modules:HTTP composition and binding
build_reference_app_router is the public composition root for the health,
console, Flow Editor, JSON-RPC, blob, and SSE surfaces. The router does not bind
a socket by itself:
GatewayHttpBinding::bind_loopback selects an available port on 127.0.0.1.
The shipping gateways return that concrete http_base_url during
initialization. Embedders may instead serve the returned Axum router on their
own listener. A host-owned Axum server must keep event_drain_task running so
mob events reach console SSE and event-log consumers. During ordered shutdown,
drain http_server, abort the event-drain task, and then shut down the runtime.
Key routes in the reference app include:
Error hook and logging
Failures the runtime detects after bootstrap (a member spawn that failed, a checkpoint that did not persist, a stalled actor loop) have no caller to return to. They are emitted as typedErrorEvents through the error hook, registered
with UnifiedRuntimeBuilder::on_error or, for hosts that construct the runtime
through UnifiedRuntime::bootstrap, with UnifiedRuntime::set_error_hook.
The hook is fire-and-forget: it runs on a detached task, and a slow or failing
hook cannot break the runtime. An attached identity-first runtime receives the
same hook.
ErrorEvent is #[non_exhaustive] and serializes with an internal
category tag in snake_case, so match with a wildcard arm and branch on
category on the wire. The variants and where the runtime fires them:
Default sink (since 0.8.18). Every
ErrorEvent is also logged through
tracing whether or not a hook is registered: at ERROR, or at INFO for
actor_loop_recovered, with a hook_registered field. A host that never
registers a hook additionally gets one WARN, no error hook is registered, so runtime error events reach logs only; register one with UnifiedRuntimeBuilder::on_error (or UnifiedRuntime::set_error_hook) to route them to paging: build() emits it at startup when on_error was never
called, and the fire path emits it once per process for hosts that bootstrap
directly and install no hook.
Gateways. rpc_gateway installs a hook that forwards every event to the
SDK as the mobkit/on_error JSON-RPC notification (params are the serialized
event); register a receiver with Python .on_error(callback) or TypeScript
.onError(callback). Because that forwarding hook is always installed, the
absent-hook WARN never fires for SDK hosts; an SDK host that registers no
callback sees only the gateway’s stderr ERROR line, which the SDKs inherit by
default (see Gateway logging).
mobkit_gateway installs no hook and relies on the log sink alone. Both
binaries install a stderr tracing subscriber whose default filter is
warn,meerkat_mobkit=info,<binary>=info; RUST_LOG overrides it.
Rust library hosts must install a tracing subscriber before build().
meerkat-mobkit emits tracing events and installs no subscriber of its own.
The default sink and the absent-hook notice are both tracing lines, so a host
without a subscriber sees neither the failures nor the hint that nobody is
listening. The minimum is a stderr subscriber honouring RUST_LOG:
Error hierarchy
See also
- Quickstart - minimal bootstrap example
- Modules - module configuration
- Console guide - admin console details
- Architecture - internal design
