# `Threadline.Semantics.ActorRef`
[🔗](https://github.com/szTheory/threadline/blob/v0.9.0/lib/threadline/semantics/actor_ref.ex#L1)

Value object representing the actor who performed an audited operation.

Implements `Ecto.ParameterizedType` for use as a JSONB field in Ecto schemas.
Stored as `%{"type" => "user", "id" => "123"}` in PostgreSQL; loaded back
as `%ActorRef{type: :user, id: "123"}` in Elixir.

## Actor types

- `:user` — end user with a non-empty id
- `:admin` — administrator with a non-empty id
- `:service_account` — service account with a non-empty id
- `:job` — background job with a non-empty id
- `:system` — system process with a non-empty id
- `:anonymous` — unauthenticated actor; id is nil

# `from_map`

Deserializes an ActorRef from a plain map. Returns {:ok, ref} or {:error, reason}.

# `new`

Constructs a validated ActorRef.

Returns `{:ok, %ActorRef{}}` or `{:error, reason}` where reason is one of:
- `:unknown_actor_type` — type not in the supported list
- `:missing_actor_id` — non-anonymous actor with nil or empty id

# `to_map`

Serializes an ActorRef to a plain map for JSONB storage.

---

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