# `Raxol.Core.Runtime.Directive.Executor`
[🔗](https://github.com/DROOdotFOO/raxol/blob/v2.8.0/lib/raxol/core/runtime/directive/executor.ex#L1)

Protocol for executing runtime directives.

Built-in implementations cover `Raxol.Core.Runtime.Directive.{Stop, Schedule, Spawn}`.
Packages register additional directive types by defining a struct and
implementing this protocol for it. raxol_agent provides impls for
`Raxol.Agent.Directive.{Async, Shell, SendAgent}`; raxol_payments and
raxol_earn provide their own.

## Context

The `context` map carries at minimum:

  * `:pid` - process to receive `{:command_result, payload}` messages
  * `:runtime_pid` - process to receive runtime-level signals (e.g. quit)

The Dispatcher additionally supplies `:turn_id` — a snapshot of the agent
turn that minted the command (nil outside a turn). Implementations whose
results may land after the minting turn closed SHOULD echo it back using the
tagged form `{:command_result, payload, %{turn_id: turn_id}}` so the result
is attributed to its originating turn; the plain 2-tuple remains valid and
is attributed to the turn current at delivery time (nil between turns).

Effect messages land at `context.pid` as `{:command_result, payload}` (or
the tagged 3-tuple above). Consumers rely on the asynchronous result message
rather than the return value of `execute/2`.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `execute`

```elixir
@spec execute(t(), context :: map()) :: any()
```

---

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