# `JidoGralkor.Canonical`
[🔗](https://github.com/elimydlarz/jido_gralkor/blob/main/lib/jido_gralkor/canonical.ex#L1)

Converts a Jido/ReAct turn into Gralkor's canonical message shape.

Gralkor accepts a flat list of `%Gralkor.Message{role, content}` where
`role ∈ {"user", "assistant", "behaviour"}`. Adapter responsibility:

  * render the Jido ReAct event trace into `"behaviour"` messages
    using whatever textual form reads well for distillation;
  * filter events that aren't memory-worthy.

The `user_query` passed in is expected to be the user's actual words —
not enriched with memory blocks, identity envelopes, or any other
harness-injected context. In the hexagonal split, prompt-time
enrichment belongs in a `Jido.AI.Reasoning.ReAct.RequestTransformer`
that wraps context for the LLM but leaves `:query` alone, so downstream
state (buffer, request store, capture) never carries injected junk.

The server never branches on interior structure — only on role. The
LLM is forgiving about the exact `behaviour` wording, so the rendering
here is free to evolve.

# `outcome`

```elixir
@type outcome() :: {:completed, String.t()} | {:failed, term()}
```

# `to_messages`

```elixir
@spec to_messages(String.t(), [map()], outcome()) :: [Gralkor.Message.t()]
```

Normalise a Jido/ReAct turn into a list of canonical Gralkor messages.

Returns `[]` when there's nothing worth persisting — callers use that
to skip the capture call entirely.

---

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