Jido.Signal.Journal (Jido v1.1.0-rc.2)

View Source

The 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

Types

t()

The journal maintains the graph of signals and their relationships

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

query_opts()

@type query_opts() :: [
  type: String.t() | nil,
  source: String.t() | nil,
  after: DateTime.t() | nil,
  before: DateTime.t() | nil
]

t()

@type t() :: %Jido.Signal.Journal{adapter: module(), adapter_pid: pid() | nil}

The journal maintains the graph of signals and their relationships

Functions

get_cause(journal, signal_id)

@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

get_conversation(journal, conversation_id)

@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

get_effects(journal, signal_id)

@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

new(adapter \\ Jido.Signal.Journal.Adapters.InMemory)

@spec new(module()) :: t()

Creates a new journal with the specified persistence adapter.

query(journal, opts \\ [])

@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

record(journal, signal, cause_id \\ nil)

@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}

trace_chain(journal, signal_id, direction \\ :forward)

@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