Expand description
Proc is an addressable actor-runtime boundary.
It owns actor lifecycle (spawn, run, terminate), routes messages to local actors, forwards messages for remote destinations, and hosts supervision state.
It also stores bounded snapshots of terminated actors for post-mortem introspection.
§Client instance invariants (CI-*)
- CI-1 (client status):
IntrospectMessage::Queryon an introspectable instance returnsstatus: "client"andactor_type: "()"in attrs. - CI-2 (snapshot on drop): Dropping the returned
Instance<()>transitions its status to terminal, causing the introspect task to store a terminated snapshot.
§Actor identity invariants (AI-*)
- AI-1 (named-child uid): Each child gets a globally unique random uid. Named children carry a label for display purposes.
- AI-3 (controller ActorAddr uniqueness): Each named child gets a unique uid; the label is informational only.
§Flight recorder span invariants (FR-*)
- FR-1 (recording-span route equivalence):
Instance::recording_span()returns a span bound to the same actor-localRecordingconsumed by handler instrumentation and introspection. Events emitted under that span land in the same flight-recorder ring buffer returned byintrospect_payload(). - FR-2 (recording-span rootness): Every span returned by
Instance::recording_span()is a fresh root span (parent: None). Ambient tracing context does not cause events emitted under that span to route into a parent actor’s flight recorder. - FR-3 (fresh-handle, stable-destination): Repeated calls to
Instance::recording_span()return distinct span handles, but all target the same underlying actor recording.
§Queue depth accounting invariants (PD-5*)
- PD-5a: Per-actor queue depth counts work items enqueued for
handler execution but not yet received from
work_rx. - PD-5b: Queue depth is incremented exactly once on every
enqueue into the actor work queue (in
HandlerPorts::get). - PD-5c: Queue depth is decremented exactly once on every
dequeue from
work_rx(in the actorrunloop). - PD-5d: Queue depth is intended to be non-negative; tests must cover ordered/buffered delivery paths to validate the accounting.
- PD-5e:
queue_depthand the OTelACTOR_MESSAGE_QUEUE_SIZEcounter are two consumers of one accounting path. Theaccount_enqueue/account_dequeuehelpers update both together so they cannot drift.
§Retained queue-pressure invariants (PD-6 through PD-9)
ProcQueueStats holds proc-level retained evidence of queue
pressure. These are runtime-driven (not publish-time sampled)
so they capture between-publish bursts.
- PD-6:
high_water_mark >= running_totaleventually. Becauserunning_totalis incremented beforehigh_water_markis updated, a concurrent reader may transiently observetotal > high_water_mark. This is a sampling artifact, not an accounting error. - PD-7:
last_nonzero_age_ms() == Noneiff proc queue depth has never been non-zero since startup. The timestamp is updated on enqueue and on dequeue when the queue remains non-zero, so it reflects the last observed non-zero state. - PD-8: transient bursts that drain before publish still update both the high-water mark and the last-nonzero state.
- PD-9:
last_nonzero_age_ms()is expected to be non-decreasing during quiet periods, but this is not a hard guarantee — the implementation usesSystemTime(wall clock), which can move backward on NTP adjustments. Callers should treat the age as best-effort telemetry, not a monotonic invariant.
Structs§
- Actor
Instance - Structured return type for
Proc::actor_instance. - Attach
Request - Sentinel message sent by an attach client as its first
MessageEnvelope. Hosts use this to distinguish attach requests from regular inboundMessageEnvelopeconnections. - Attach
Rx Rx<MessageEnvelope>adapter that unwrapsHost2Client::Envelopefrom a duplex receiver.- Bootstrap
Assignment - Identity assignment sent by a host as the first message on a duplex
attach connection. The child reads this to learn its
ProcAddr. - Builder
- Builder for constructing a
Procwith explicit identity and connectivity. - Context
- Context for a message currently being handled by an Instance.
- Global
Gateway - Builder state that attaches the proc to the process-wide global gateway.
- Handler
Ports - A polymorphic dictionary that stores runtime-dispatched handler ports. The interface memoizes the ports so that they are reused. We do not (yet) support stable identifiers across multiple instances of the same actor.
- Instance
- An actor instance. This is responsible for managing a running actor, including its full lifecycle, supervision, signal management, etc. Instances can represent a managed actor or a “client” actor that has joined the proc.
- Instance
Cell - InstanceCell contains all of the type-erased, shareable state of an instance. Specifically, InstanceCells form a supervision tree, and is used by ActorHandle to access the underlying instance.
- Instance
Receivers - Receivers created by
Instance::newthat must be threaded to their respective consumers (actor loop, introspect task, etc.). - Private
Gateway - Builder state that creates a private gateway with a custom forwarder.
- Proc
- A proc instance is the runtime managing a single proc in Hyperactor. It is responsible for spawning actors in the proc, multiplexing messages to/within actors in the proc, and providing fallback routing to external procs.
- Shared
Gateway - Builder state that attaches the proc to a shared gateway.
- Weak
Instance Cell - A weak version of the InstanceCell. This is used to provide cyclical linkage between actors without creating a strong reference cycle.
- Weak
Proc - A weak reference to a Proc that doesn’t prevent it from being dropped.
- Work
Cell - Represents a single work item used by the instance to dispatch to actor handles. Specifically, this enables handler polymorphism.
Enums§
- Host2
Client - Wire protocol for the host -> client direction on a duplex attach connection.
Constants§
- LEGACY_
LOCAL_ PROC_ NAME - Legacy singleton proc name used for host-local client actors.
- LEGACY_
SERVICE_ PROC_ NAME - Legacy singleton proc name used for host system actors.