SIGN IN SIGN UP

Add rc.semverCompare custom operator (#4077)

### Checklist
- [ ] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-ios` and
hybrids

### Motivation

Port of RevenueCat/purchases-ios#7472. Version targeting is the most
common audience condition, and the built-in `<` / `>` compare strings,
so they rank `"10.0.0"` below `"9.0.0"`.

### Description

`{"rc.semverCompare": [left, right]}` returns `-1`, `0`, or `1`,
composing with the existing comparison operators:

```json
{">=": [{"rc.semverCompare": [{"var": "appVersion"}, "2.1.0"]}, 0]}
```

Precedence follows semver 2.0.0 §11, with build metadata excluded.
Unparseable input and inexact arity throw `typeMismatch`; partial
versions (`"2.1"` ≡ `"2.1.0"`) and leading zeros are accepted.

### Notes

- Thirty-three fixtures copied byte-for-byte from iOS (482 total).
- Components parse as `Long`, not `Int`, so one wider than 32 bits
compares as it does on iOS, where Swift's `Int` is 64-bit.
- The iOS PR is still in review, so its fixtures could still change;
this file must be re-synced if they do.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes audience/rule evaluation behavior for version gates; incorrect
semver logic could mis-target users, but scope is isolated to a new
operator with broad fixture coverage.
> 
> **Overview**
> Adds **`rc.semverCompare`** to the rules engine so audience predicates
can compare app versions by **semver 2.0.0 precedence** instead of
lexicographic string order (e.g. `10.0.0` vs `9.0.0`).
> 
> The operator takes two version **strings**, returns **`-1` / `0` /
`1`**, and composes with existing comparators—for example `{">=":
[{"rc.semverCompare": [{"var": "appVersion"}, "2.1.0"]}, 0]}`.
Implementation strips build metadata, pads short cores (`"2.1"` →
`2.1.0`), and rejects bad arity or unparseable input with
**`typeMismatch`**.
> 
> **`CustomOperators`** dispatches the new op; **`rc_semver.json`** adds
33 conformance fixtures (fixture count guard bumped to **501**), aligned
with the iOS port.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
60a7b39070518f70e75878425d1d197c27be419f. 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: Cursor <cursoragent@cursor.com>
A
Antonio Pallares committed
9e1e8eb04086226c7b50670e422d22c7feeed70f
Parent: 9d79082
Committed by GitHub <noreply@github.com> on 8/25/2026, 11:13:19 AM