Skip to content

feat(Checkpoints): consume canonical audience configuration - #7543

Open
rickvdl wants to merge 13 commits into
mainfrom
rickvdl/canonical-audience-config
Open

feat(Checkpoints): consume canonical audience configuration#7543
rickvdl wants to merge 13 commits into
mainfrom
rickvdl/canonical-audience-config

Conversation

@rickvdl

@rickvdl rickvdl commented Aug 28, 2026

Copy link
Copy Markdown
Member

Description

With this PR we're now reading one static blob with all audience rules from the remote config infrastructure, as well as an object of backend_predicate_results, which contains the backend computed facts that we should fill in at the placeholders in the rules of the audiences blobs.

Changes

This PR contains the following:

  • Fetching, decoding, storing and caching the static blob of audiences through the existing remote config infrastructure
  • Reading and decoding the backend_predicate_results object from the audiences topic. This object is kept in memory for easy access.
    • We'll be using bool's for now, but any value that works in the rules evaluator (DimensionValue) should work here, for future extensibility.
  • The facts from backend_predicate_results are passed into the rules evaluator through the backendValues. Ensuring that these values are used in rules (through the backend.* dimension) where these variables are mentioned

Related Android PR


Note

Medium Risk
Changes checkpoint targeting, remote-config key handling, and audience loading paths; mis-decoding or generation mismatches could cause incorrect matches or spurious configuration-unavailable outcomes.

Overview
Checkpoint resolution now loads one generation-bound audience snapshot (rules from the default blob plus inline backend_predicate_results) instead of looking up audiences live, and passes subscriber-specific facts into rule evaluation as backend.* dimensions alongside custom.*.

Checkpoint workflow resolver retries resolution once when checkpoint or audience config goes stale mid-flight, keeps checkpoint rules and audience data on the same config generation, and feeds backendPredicateResults into the local rules matcher so audience predicates can reference hashed backend placeholders.

Remote config decoding preserves exact wire keys in ConfigItem.content (including opaque condition hashes and snake_case fields like offering_identifier), which workflows and audience metadata rely on. AudiencesConfigProvider decodes the canonical audience map from the prefetched blob, tolerates per-audience decode failures, and converts supported AnyDecodable values to DimensionValue for rules.

Tests cover retry/stale behavior, backend predicate matching (booleans and other dimension types), and the new audiences topic shape.

Reviewed by Cursor Bugbot for commit c62b9aa. Bugbot is set up for automated code reviews on this repo. Configure here.

@RevenueCat-Danger-Bot

RevenueCat-Danger-Bot commented Aug 28, 2026

Copy link
Copy Markdown

⚠️ Warnings

This PR changes 396 lines of production Swift (limit 300); skipped via skip-pr-lines-changed-check label.

@rickvdl
rickvdl force-pushed the rickvdl/canonical-audience-config branch from 54c6fc2 to 3190ab1 Compare August 28, 2026 13:28
Comment thread Sources/Networking/Responses/RemoteConfiguration.swift
@rickvdl

rickvdl commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@RCGitBot please test

Comment thread Sources/LocalRules/DimensionProvider.swift

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense! Just some non-blocker comments

Comment thread Sources/Networking/AudiencesConfigProvider.swift
Comment thread Sources/Networking/AudiencesConfigProvider.swift Outdated
Comment thread Sources/Networking/Responses/RemoteConfiguration.swift
Comment thread Sources/Checkpoints/CheckpointWorkflowResolver.swift
Base automatically changed from rickvdl/checkpoints-web-checkout-outcome to main September 1, 2026 14:29
@rickvdl
rickvdl force-pushed the rickvdl/canonical-audience-config branch from 02f5906 to 688af77 Compare September 1, 2026 14:31
Comment thread Sources/Networking/Responses/RemoteConfiguration.swift Outdated
Comment thread Sources/Networking/AudiencesConfigProvider.swift Outdated
Comment thread Sources/LocalRules/AnyDecodable+DimensionValue.swift

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some more comments!

Comment thread Sources/Checkpoints/CheckpointWorkflowResolver.swift Outdated
Comment thread Sources/Checkpoints/CheckpointWorkflowResolver.swift Outdated
@rickvdl
rickvdl force-pushed the rickvdl/canonical-audience-config branch from 688af77 to 0271dc8 Compare September 2, 2026 11:58
@rickvdl

rickvdl commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@RCGitBot please test

@rickvdl

rickvdl commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@RCGitBot please test

@rickvdl

rickvdl commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@RCGitBot please test

@rickvdl
rickvdl marked this pull request as ready for review September 4, 2026 11:36
@rickvdl
rickvdl requested a review from a team as a code owner September 4, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants