# `AshReplicant.Apply`
[🔗](https://github.com/baselabs/ash_replicant/blob/v0.3.0/lib/ash_replicant/apply.ex#L1)

Applies one `%Replicant.Change{}` to the mirror. An insert/update goes through a
single-row Ash action; a delete issues one atomic `bulk_destroy` over a PK-filtered
query; a `:mirror` truncate deletes the mirror table directly.

Called once per change, in delivery (`ordinal`) order, inside the sink's
transaction. Raises on any failure so the surrounding `Repo.transaction`
rolls the whole transaction back — the effect-once fail-closed contract.
Never re-orders or coalesces changes: a spilled transaction's `changes` is a
lazy single-pass Enumerable, so the caller iterates it exactly once.

# `apply_change`

```elixir
@spec apply_change(map(), Replicant.Change.t(), DateTime.t() | nil) :: :ok
```

Apply a change under `config` (`%{resolver_index:, repo:, authorize?:}`).
Returns `:ok`; raises `AshReplicant.Error` (value-free) on failure.
A change whose `{schema, table}` is not a mirror target is ignored.

`commit_timestamp` (optional, defaults to `nil`) is the change's transaction
commit time, threaded through for SCD2 dispatch; unused on the SCD1 path.

---

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