Skip to content

feat(openfeature): expose dynamic offline rules (FFL-2837 PR3) - #1348

Draft
btthomas wants to merge 9 commits into
blake.thomas/FFL-2837-PR2from
blake.thomas/FFL-2837-PR3
Draft

feat(openfeature): expose dynamic offline rules (FFL-2837 PR3)#1348
btthomas wants to merge 9 commits into
blake.thomas/FFL-2837-PR2from
blake.thomas/FFL-2837-PR3

Conversation

@btthomas

@btthomas btthomas commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Pull request stack

  1. Plan PR (#1345)
  2. PR1: Rules engine boundary (#1346)
  3. PR2: Dynamic offline evaluation (#1347)
  4. PR3: Provider API and documentation (feat(openfeature): expose dynamic offline rules (FFL-2837 PR3) #1348) <- you are here

This description uses Simplified Technical English. Technical names and API names do not change.

Summary

This PR exposes dynamic offline rules through the existing offline provider.

  • The offline provider passes the effective OpenFeature context and logger to FlagsClient.
  • The online provider keeps its current cache path.
  • An empty OpenFeature context lets FlagsClient use its stored context.
  • A missing targeting key stays missing. The SDK does not replace it with an empty string.
  • Rules configurations stay ready after context changes.
  • Context changes do not fetch configurations.
  • Integration tests cover two subjects, two results, and TARGETING_KEY_MISSING.
  • The README explains precomputed, rules, and mixed configurations.
  • The README warns that untrusted regular expressions can block the JavaScript thread.
  • Both example applications include a rules-context switch.

Reason

The provider lifecycle already supports offline configuration and context changes. The provider only needs to pass the current resolution context to the core rules path. A new provider class is not required.

When OpenFeature supplies no effective context, the provider passes undefined to the internal resolution method. This preserves an embedded precomputed context. The provider still passes the OpenFeature logger.

OpenFeature hook constraint

Web SDK 1.8 freezes the hook context before it calls before hooks. It does not accept a replacement context from a hook. This PR does not claim that a hook can replace one resolution context.

Temporary upstream code

This PR adds three fixture TODO(FFL-2837) markers:

  • One in the standard example
  • One in the new-architecture example
  • One in the real-provider integration test

The complete stacked branch contains 12 markers. PR1 and PR2 contain the other nine markers.

The three PR3 fixtures use the legacy rulesBased JSON wire. Replace them with one canonical version 1 rules.response base64 fixture after a published flagging-core release contains openfeature-js-client#344. Reuse that fixture for the Metro, Hermes, and JSC checks.

Tracking metadata is not an upstream blocker. Rules assignments use the existing native bridge.

User impact

A customer can load one rules configuration and call OpenFeature.setContext for new subjects. The provider evaluates each context locally. It does not fetch assignments.

Precomputed-only behavior does not change. Matching precomputed data has priority when both branches exist.

Keep the original wire when it contains rules. configurationToString cannot recreate the protobuf rules payload.

Remaining gates

  • Publish and pin the flagging-core release that contains PR Add Support for RN 0.71 #344.
  • Replace the three legacy fixture branches.
  • Define the regular-expression, salt, size, and security policies.
  • Run the packed dependency and rules flow in Hermes and JSC.

This PR remains a draft until these gates are complete.

Checks

  • yarn tsc --noEmit -p packages/core/tsconfig.json
  • yarn tsc --noEmit -p packages/react-native-openfeature/tsconfig.json
  • yarn tsc --noEmit -p example-new-architecture/tsconfig.json
  • Targeted ESLint for the provider and core files
  • 34 OpenFeature tests
  • 103 core flags tests
  • Formatting and git diff --check

@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from cb5597d to 932c87b Compare July 27, 2026 20:13
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from dbf9a5f to ec8e68a Compare July 27, 2026 20:28
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 932c87b to a725eb5 Compare July 28, 2026 19:47
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch 2 times, most recently from d6670ab to b4dc7a4 Compare July 29, 2026 14:27
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch 2 times, most recently from 45a8242 to 0cc9e56 Compare July 30, 2026 13:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from b4dc7a4 to f668b3f Compare July 30, 2026 13:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 0cc9e56 to 31018a5 Compare July 31, 2026 13:58
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from f668b3f to b612833 Compare July 31, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant