# `Kinda.CallbackRuntime`
[🔗](https://github.com/beaver-lodge/kinda/blob/main/lib/kinda/callback_runtime.ex#L1)

Executes the BEAM side of a native callback and completes its reply token.

The native consumer supplies its own two-argument reply NIF. Callback
functions return `{:ok, value}` or `{:error, value}` so domain adapters can
retain their own state and diagnostics semantics while Kinda owns the common
success/failure and exception boundary.

# `callback_result`

```elixir
@type callback_result(value) :: {:ok, value} | {:error, value}
```

# `outcome`

```elixir
@type outcome(value) ::
  callback_result(value)
  | {:exception, :error | :exit | :throw, term(), Exception.stacktrace()}
```

# `invoke`

```elixir
@spec invoke(
  reply_token :: term(),
  callback :: (-&gt; callback_result(value)),
  reply :: (term(), boolean() -&gt; term()),
  before_reply :: (outcome(value) -&gt; term())
) :: outcome(value)
when value: term()
```

# `invoke_reply`

```elixir
@spec invoke_reply(
  reply_token :: term(),
  callback :: (-&gt; callback_result(value)),
  reply :: (term(), outcome(value) -&gt; term()),
  before_reply :: (outcome(value) -&gt; term())
) :: outcome(value)
when value: term()
```

Executes a callback and gives the complete normalized outcome to a
consumer-defined reply function.

This is the projection boundary for callback ABIs whose return is richer
than success/failure. A consumer may encode a scalar or enum result, or
validate a resource and project its native handle, before completing the
reply token.

---

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