Canonical runtime identity envelope and Phoenix-edge adapters.
Use this module where request assigns, session values, or mount params cross
into Scoria's runtime boundary. It normalizes those host-owned inputs into the
public identity shape used by Scoria.start_run/2.
actor_id and tenant_id identify who is acting and for whom. session_id
is the host-owned continuity key that groups related turns. It is not a
substitute for Scoria's durable run_id, which identifies one exact run for
resume and operator evidence.
from_conn_assigns/1, from_session/1, and from_mount/1 exist so Phoenix
apps can normalize edge state before they call the public runtime facade.
Examples
iex> identity =
...> Scoria.Identity.from_session(%{
...> "actor_id" => "actor-1",
...> "tenant_id" => "tenant-1",
...> "session_id" => "session-1"
...> })
iex> Scoria.Identity.to_map(identity)
%{actor_id: "actor-1", tenant_id: "tenant-1", session_id: "session-1", metadata: %{}}
iex> normalized =
...> Scoria.Identity.normalize(%{
...> actor: %{id: "actor-2"},
...> tenant: %{id: "tenant-2"},
...> session: %{id: "session-2"}
...> })
iex> {normalized.actor_id, normalized.tenant_id, normalized.session_id}
{"actor-2", "tenant-2", "session-2"}