# `ExWapp.Session.Outbound.DeviceDiscovery`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/session/outbound/device_discovery.ex#L1)

Pure device-discovery decisions for outbound messages.

The worker remains responsible for USync I/O, cache reads, and logging. This
module builds query identities and turns those inputs into normalized
recipient and linked-device target sets.

# `resolution`

```elixir
@type resolution() :: %{
  recipient_devices: [String.t()],
  recipient_cached_devices: [String.t()],
  own_devices: [String.t()],
  own_cached_devices: [String.t()],
  all_usync_devices: [String.t()],
  all_device_jids: [String.t()]
}
```

# `resolution_context`

```elixir
@type resolution_context() :: %{
  device_map: map(),
  recipient_base_jid: String.t(),
  recipient_cached_devices: [String.t()],
  own_sender_jid: String.t(),
  own_base_jid: String.t(),
  own_lid_jid: String.t(),
  own_cached_devices: [String.t()],
  own_device_id: integer(),
  lid_mapping: map()
}
```

# `own_preferred_jid`

```elixir
@spec own_preferred_jid(term(), term()) :: String.t()
```

Selects the preferred local identity for cache and fanout resolution.

# `query_jids`

```elixir
@spec query_jids(term(), term(), term(), term(), map()) :: [String.t()]
```

Builds the USync query set for a recipient and all local identity families.

# `resolve`

```elixir
@spec resolve(resolution_context()) :: resolution()
```

Resolves normalized recipient, linked-device, and aggregate device sets.

# `resolve_identity_devices`

```elixir
@spec resolve_identity_devices(map(), term(), map()) :: [String.t()]
```

Resolves USync devices for one identity, preferring its current JID family.

---

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