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

SCD2 (validity-windowed) apply strategy, dispatched from `Apply.apply_change/3` when
`Info.history_scd2?(resource)`. Each change CLOSES the current open version (an Ash
`bulk_update` through the host close action, tenant-scoped, so it never retires
another tenant's identically-keyed version) and OPENS a new version (host `:create`
upsert by the `(business_key, valid_from_lsn)` identity), inside the sink's outer
transaction (`transaction: false`). Op-dependent close predicate: the re-opened record's
close uses `valid_from_lsn < lsn` (don't clobber the version being re-opened at `lsn`); a
TERMINAL close — a delete, or the retired OLD key of a pk-changing update — uses
`valid_from_lsn <= lsn` (retire a version opened in the same commit too). Value-free: every
raising op is scrubbed to a structural reason.

# `apply`

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

---

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