Add Scope plumbing and custom operator extension point (#4047)
### Checklist
- [x] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-ios` and
hybrids
### Motivation
Port of RevenueCat/purchases-ios#7433, the first of the rules-engine
custom operator PRs. Custom `rc.*` operators need somewhere to live, and
`rc.rootVar` needs the predicate's root data to survive iteration, which
today is lost as soon as `some` / `map` / `reduce` rebind the scope to
the current item.
### Description
- Thread a `Scope` (current data plus the never-replaced root) through
the evaluator instead of a bare `Value`, and delegate unknown operators
to an empty `CustomOperators` dispatcher.
- Behavior-preserving: `var` still sees only the current item inside
iteration, no fixtures were added or changed, and the pinned fixture
count stays at 382.
### Notes
The `@Suppress("UnusedParameter")` on the empty dispatcher is temporary
— `args` and `vars` become used as soon as the first `rc.*` operator
lands.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches the rules-engine evaluator and every operator signature, so a
scope mix-up could change predicate results. Intended to be
behavior-preserving for existing var/iteration semantics.
>
> **Overview**
> Prepares the rules engine for RevenueCat `rc.*` operators by replacing
a bare data `Value` with a `Scope` that keeps both **current** data and
the original **root**.
>
> Iteration (`some`/`all`/`none`/`map`/`filter`/`reduce`) now rebinds
only `current` via `scoped()`, so `var` still sees the item (or reduce’s
`{current, accumulator}`) while custom ops can later read top-level
data. Unknown operators fall through to an empty `CustomOperators`
dispatcher (still `UnsupportedOperator`). `firstArgEvaluated` moves onto
`Operators`.
>
> No new operator behavior; tests wrap existing calls in `Scope`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fa1fa3c1a99686840262c89a70c0ddc5dccd79e0. 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
40e3de616eb048906be320f7eefb692324d20f78
Parent: 2dbe19e
Committed by GitHub <noreply@github.com>
on 8/21/2026, 11:56:13 AM