Jido.Signal.Journal (Jido v1.1.0-rc.2)
View SourceThe Signal Journal tracks and manages signals between agents, maintaining causality and conversation relationships. It provides a directed graph of signals that captures temporal ordering and causal relationships.
Summary
Functions
Gets the cause of a given signal.
Gets all signals in a conversation.
Gets all effects (signals caused by) of a given signal.
Creates a new journal with the specified persistence adapter.
Queries signals based on criteria.
Records a new signal in the journal.
Traces the complete causal chain starting from a signal.
Types
@type query_opts() :: [ type: String.t() | nil, source: String.t() | nil, after: DateTime.t() | nil, before: DateTime.t() | nil ]
The journal maintains the graph of signals and their relationships
Functions
@spec get_cause(t(), String.t()) :: Jido.Signal.t() | nil
Gets the cause of a given signal.
Parameters
- journal - The current journal state
- signal_id - The ID of the signal to get the cause for
Returns the causing signal or nil if none exists
@spec get_conversation(t(), String.t()) :: [Jido.Signal.t()]
Gets all signals in a conversation.
Parameters
- journal - The current journal state
- conversation_id - The ID of the conversation to fetch
Returns a list of signals in chronological order
@spec get_effects(t(), String.t()) :: [Jido.Signal.t()]
Gets all effects (signals caused by) of a given signal.
Parameters
- journal - The current journal state
- signal_id - The ID of the signal to get effects for
Returns a list of signals in chronological order
Creates a new journal with the specified persistence adapter.
@spec query(t(), query_opts()) :: [Jido.Signal.t()]
Queries signals based on criteria.
Options
- type - Filter by signal type
- source - Filter by signal source
- after - Filter signals after this time
- before - Filter signals before this time
Returns a list of signals matching all criteria, in chronological order
@spec record(t(), Jido.Signal.t(), String.t() | nil) :: {:ok, t()} | {:error, atom()}
Records a new signal in the journal.
Parameters
- journal - The current journal state
- signal - The signal to record
- cause_id - Optional ID of the signal that caused this one
Returns {:ok, journal}
or {:error, reason}
@spec trace_chain(t(), String.t(), :forward | :backward) :: [Jido.Signal.t()]
Traces the complete causal chain starting from a signal.
Parameters
- journal - The current journal state
- signal_id - The ID of the signal to trace from
- direction - :forward for effects chain, :backward for causes chain
Returns a list of signals in causal order