SIGN IN SIGN UP

Evaluate checkpoint audiences before resolving workflows (#3971)

Evaluates the audience explicitly before the checkpoint answers with a
workflow.

Audience definitions are stored inline in `ConfigItem.metadata`, without
a `blob_ref`, so `AudiencesConfigProvider` now reads and decodes the
topic metadata directly.


[WFL-464](https://linear.app/revenuecat/issue/WFL-464/android-deserialize-audience-rules-for-rules-engine-evaluation).

Validation: `:purchases:compileDefaultsDebugKotlin` and the pre-commit
Detekt check. The existing blob-backed `AudiencesConfigProviderTest`
cases were not updated as part of this fix.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes checkpoint targeting logic and remote-config read path for
audiences; misconfiguration or parse failures alter which workflow (or
no action) customers see, though behavior is fail-closed toward
configuration unavailable rather than silent wrong matches.
> 
> **Overview**
> Checkpoint resolution no longer treats every checkpoint rule as
matching via a placeholder predicate. Each rule’s `audience_id` is
resolved through **`AudiencesConfigProvider`**, and
**`LocalRulesEvaluator`** evaluates the audience’s rules JSON against
device/store/custom dimensions until the first match picks a workflow.
> 
> **`AudiencesConfigProvider`** now loads audiences from inline
remote-config topic **`metadata`** (not blob storage) and decodes them
to **`Audience`** for the rules engine.
> 
> **`PurchasesFactory`** wires **`AudiencesConfigProvider`** into the
orchestrator when remote config is enabled (absent for custom
entitlement computation). Missing or unreadable audiences surface
**`CONFIGURATION_UNAVAILABLE`** instead of **`NO_MATCH`**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fdbcf963e24eb0531497078acd04185ab399fae5. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
C
Cesar de la Vega committed
550c359711602ba3063000f27057b8d057cbd3fc
Parent: ee0ea38
Committed by GitHub <noreply@github.com> on 8/20/2026, 8:09:06 AM