# `Jidoka.Event`
[🔗](https://github.com/agentjido/jidoka/blob/v0.9.0/lib/jidoka/event.ex#L1)

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.

# `data`

```elixir
@type data() :: %{optional(atom()) =&gt; term()}
```

# `t`

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

# `build`

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

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

# `cancelled?`

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

Returns true when an event represents a cancelled turn.

# `events`

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

Returns the core event names currently emitted by Jidoka.

# `failure_reason`

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

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

# `new`

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

Builds a runtime event from keyword or map attributes.

# `new!`

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

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

# `schema`

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

Returns the Zoi schema for a runtime event.

# `to_map`

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

Projects an event into a compact map.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
