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

An Ash-native `Replicant.Sink` adapter. Mirrors a source Postgres database's
committed CDC changes into AshPostgres resources with effect-once semantics
(dup = 0, loss = 0), resolving resource, tenant, and classification in the Ash
layer while keeping `replicant` tenant-blind.

This is the `ash_postgres`-of-`replicant`: `replicant` is the tenant-blind CDC
transport; multitenancy and classification live here, one layer up.

# `start_link`

```elixir
@spec start_link(keyword()) :: {:ok, pid()} | {:error, term()}
```

Start a CDC pipeline that mirrors into Ash resources. `opts`:

  * `:sink` — a module built with `use AshReplicant.Sink` (carries repo/domains/checkpoint/slot).
  * `:connection` — Postgrex opts (point at a standby).
  * `:publication` — replication identifier.
  * `:go_forward_only`, `:snapshot` — passed through to `Replicant.start_link/1`.

The `slot_name` is NOT a `start_link` option — it is baked into the sink via
`use AshReplicant.Sink, slot_name: ...` and is the single source of truth for
both the `:persistent_term` index key and the replication slot.

Builds the `{schema,table}=>resource` index from the sink's domains, **fails
closed** on a duplicate or missing source table, caches the index in
`:persistent_term`, then starts the `replicant` pipeline.

# `stop_supervised`

```elixir
@spec stop_supervised(String.t()) :: :ok
```

Stop a running pipeline by slot name (idempotent). Clears the cached resolver
index from `:persistent_term` so a subsequent `start_link/1` rebuilds it fresh.

# `version`

```elixir
@spec version() :: String.t()
```

The library version string.

---

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