# `Chimeway.Digests`
[🔗](https://github.com/jonlunsford/chimeway/blob/v1.0.0/lib/chimeway/digests.ex#L1)

Public digest-rule persistence API for durable rule lookup and storage.

Digest flush execution closes automatically only when the configured
dispatcher is `Chimeway.Dispatch.Oban`, because bucket accumulation can then
schedule `Chimeway.Dispatch.DigestFlushWorker` from persisted
`window_ends_at` state.

Hosts using any other dispatcher still retain the durable public
`emit_bucket/2` seam and are expected to drive flush execution explicitly.
Chimeway does not imply built-in automatic digest scheduling outside the Oban
path.

# `rule_lookup`

```elixir
@type rule_lookup() :: %{
  :channel =&gt; String.t(),
  optional(:notification_key) =&gt; String.t() | nil,
  optional(:category) =&gt; String.t() | nil,
  optional(:digest_key) =&gt; String.t() | nil
}
```

# `emit_bucket`

```elixir
@spec emit_bucket(
  binary() | map(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Emits a due digest bucket and returns the canonical emitted delivery identity.

This remains the explicit host-managed flush seam when
`Chimeway.Dispatch.Oban` is not the configured dispatcher.

# `find_matching_rule`

```elixir
@spec find_matching_rule(rule_lookup()) :: Chimeway.Digests.DigestRule.t() | nil
```

Finds the first digest rule matching channel and rule selectors.

# `get_rule!`

```elixir
@spec get_rule!(binary()) :: Chimeway.Digests.DigestRule.t()
```

Fetches a digest rule by ID.

# `list_rules`

```elixir
@spec list_rules(keyword()) :: [Chimeway.Digests.DigestRule.t()]
```

Lists digest rules, optionally filtered by exact-match fields.

# `upsert_rule`

```elixir
@spec upsert_rule(map()) ::
  {:ok, Chimeway.Digests.DigestRule.t()} | {:error, Ecto.Changeset.t()}
```

Creates or updates a digest rule by stable `rule_key` and `rule_version`.

---

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