SIGN IN SIGN UP

fix(checkpoints): Fix checkpoint resolution config races (#4058)

A remote config refresh can land after checkpoint rules are read but
before their audience or workflow is resolved. That can mix config
generations and show the old workflow to a customer matched by the new
audience.

Carry the remote config generation with checkpoint rules and return
`CONFIGURATION_UNAVAILABLE` if it changes during resolution. This is the
same logic as in `purchases-ios`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes checkpoint presentation logic during concurrent remote config
updates; bounded retries may surface CONFIGURATION_UNAVAILABLE where a
mixed-generation workflow might have been shown before.
> 
> **Overview**
> Fixes a race where a remote config commit or identity change can land
**after** checkpoint rules are read but **before** audience matching or
workflow loading finishes, so the SDK could present a workflow from an
older generation than the rule that matched.
> 
> **Checkpoint rules reads** now stamp `CheckpointRulesResolution.Found`
with the current `configGeneration`, and
`CheckpointsConfigProvider.isCurrent()` lets callers detect staleness.
Reads that complete under a moved generation are treated as untrusted
(`null`) and retried **once**; a second stale read yields `Unavailable`
at the provider layer.
> 
> **Full checkpoint resolution** mirrors that pattern: `attemptResolve`
aborts with `null` if the generation changes after audience evaluation
or after `resolveRule`, and `resolve` retries exactly once before
returning **`CONFIGURATION_UNAVAILABLE`** so bursts of commits cannot
spin resolution indefinitely.
> 
> Tests cover single-change retries and repeated-change failure paths
for both config reads and end-to-end resolver behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9d0021120fbc01a4fd389c4caef0b22cfd824c08. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
C
Cesar de la Vega committed
e23606fd31b7bd7177a09df2095a56c70cf5002f
Parent: f5cee1f
Committed by GitHub <noreply@github.com> on 8/27/2026, 12:39:06 PM