Jido.AgentServer.ParentRef (Jido v2.2.0)

View Source

Reference to a logical parent agent in Jido hierarchy tracking.

ParentRef models Jido's logical parent-child relationship, which is layered on top of OTP supervision. Parent and child agents are still OTP peers under a supervisor; the parent relationship is represented explicitly with this struct, child-start signals, and process monitors.

While a child is attached, the runtime injects this value into agent.state.__parent__ so child actions can use Directive.emit_to_parent/3. If the child becomes orphaned, the current parent ref is cleared and the former parent is moved to agent.state.__orphaned_from__.

Summary

Functions

Creates a new ParentRef from a map of attributes.

Creates a new ParentRef from a map, raising on error.

Validates that a value is a valid ParentRef.

Types

t()

@type t() :: %Jido.AgentServer.ParentRef{
  id: binary(),
  meta: map(),
  partition: nil | any(),
  pid: any(),
  tag: any()
}

Functions

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, term()}

Creates a new ParentRef from a map of attributes.

Returns {:ok, parent_ref} or {:error, reason}.

new!(attrs)

@spec new!(map()) :: t()

Creates a new ParentRef from a map, raising on error.

validate(parent_ref)

@spec validate(term()) :: {:ok, t()} | {:error, term()}

Validates that a value is a valid ParentRef.