# `AshVersioned.IdentityScoping`

Determines whether an `Ash.Resource.Identity` is usable on an `AshVersioned.Resource`.
All user-defined identities on a versioned resource must conform to exactly one of these
constraints:

- it must have a partial lookup `where latest == true`; or
- it must be a superset of the full record history (`{identity, version}`) and must not
  have a partial lookup `where latest == true`; or

Identity definitions that do not follow these conventions will eventually trip the
uniqueness guarantees provided by the default identities. The functions in this module
are used by `AshVersioned.Verifiers.VerifyIdentityScoping` to ensure that invalid
identities are caught at compile time, and by `AshVersioned.Transformers.AddFields` to
ensure that partial indexes are created correctly.

Additional conditions for partial lookups are not currently supported.

# `full_history_composite?`

Returns `true` if `identity`'s keys include both `identity_field` and `version_field`
and does not include `latest_field`.

# `safe?`

Returns `true` if `identity` conforms to one of the two required indexes.

# `scoped_to_latest?`

Returns `true` if the identity `where` clause is `{latest} == true`.

Complex `where` expressions are rejected.

---

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