Jidoka.Event (Jidoka v0.9.0)

Copy Markdown View Source

Core event emitted by Jidoka turn transitions.

Events are neutral turn data. Runtime, trace, streaming, and UI modules may project or consume them, but workflow/state modules should only emit the event data itself.

Summary

Functions

Builds a core event with defaults for known Jidoka event names.

Returns true when an event represents a cancelled turn.

Returns the core event names currently emitted by Jidoka.

Returns the failure reason carried by a turn-failed event.

Builds a runtime event from keyword or map attributes.

Builds a runtime event and raises if the attributes are invalid.

Returns the Zoi schema for a runtime event.

Projects an event into a compact map.

Types

data()

@type data() :: %{optional(atom()) => term()}

t()

@type t() :: %Jidoka.Event{
  agent_id: nil | nil | binary(),
  category:
    ((((((:workflow | :effect) | :runtime) | :operation) | :control)
      | :approval)
     | :result)
    | :memory,
  data: map(),
  effect_id: nil | nil | binary(),
  effect_kind: :llm | :operation,
  error: nil | nil | any(),
  event:
    ((((((((((((((((((((((((:llm_delta | :turn_finished) | :turn_hibernated)
                          | :turn_failed)
                         | :control_blocked)
                        | :control_interrupted)
                       | :control_failed)
                      | :turn_started)
                     | :prompt_assembled)
                    | :effect_planned)
                   | :effect_started)
                  | :effect_replayed)
                 | :effect_completed)
                | :effect_failed)
               | :capability_call_started)
              | :capability_call_completed)
             | :capability_call_failed)
            | :control_allowed)
           | :approval_requested)
          | :approval_responded)
         | :approval_applied)
        | :result_validated)
       | :result_repair_requested)
      | :memory_recalled)
     | :memory_written)
    | :operation_observed,
  loop_index: nil | nil | integer(),
  operation: nil | nil | binary(),
  phase:
    ((((((((:start | :control) | :review) | :memory) | :assemble_prompt)
        | :plan_model_effect)
       | :interpret_effect)
      | :validate_result)
     | :apply_operation_results)
    | :finish,
  request_id: nil | nil | binary(),
  seq: integer(),
  status:
    ((((:planned | :pending) | :started) | :replayed) | :completed) | :failed
}

Functions

build(event, existing_events \\ [], attrs \\ [])

@spec build(atom(), list(), keyword() | map()) :: t()

Builds a core event with defaults for known Jidoka event names.

cancelled?(event)

@spec cancelled?(t()) :: boolean()

Returns true when an event represents a cancelled turn.

events()

@spec events() :: [atom()]

Returns the core event names currently emitted by Jidoka.

failure_reason(event)

@spec failure_reason(t()) :: term()

Returns the failure reason carried by a turn-failed event.

new(attrs)

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

Builds a runtime event from keyword or map attributes.

new!(attrs)

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

Builds a runtime event and raises if the attributes are invalid.

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for a runtime event.

to_map(event)

@spec to_map(t()) :: map()

Projects an event into a compact map.