Skip to content

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

Draft
btthomas wants to merge 13 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 13 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 every effective OpenFeature context to FlagsClient.
  • The provider treats {} as a real context.
  • clearContext() does not restore a context from the configuration.
  • A missing targeting key stays missing.
  • Rules configurations stay ready after context changes.
  • Context changes do not fetch configurations.
  • Configuration parse failures produce provider errors.
  • Recovery emits Ready before ConfigurationChanged.
  • Integration tests cover rules, mixed data, parse errors, recovery, and missing targeting keys.
  • The README explains precomputed, rules, and mixed configurations.
  • Both example applications include a rules-context switch.

Reason

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

OpenFeature supplies {} for an unset or cleared global context. The provider cannot distinguish this state from an explicit {}. Therefore, it passes {} literally. For a context-specific precomputed configuration, the application explicitly sets the context returned by getPrecomputedContext(configuration).

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. The complete stacked branch contains 19 markers. PR1 and PR2 contain the other 16 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 through 939da97 and the required SHA digest validation follow-up.

Commits ab22ad0 and 939da97 only refresh generated Node-server declarations and isolate browser provider tests. They do not change the fixture or runtime contract. PR #336 is currently at 6d3d6a4 and adds no new logical behavior in its latest restack.

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.

A precomputed customer must explicitly set the matching OpenFeature context. An empty context does not select the embedded configuration context.

Matching precomputed data has priority when both branches exist. Keep the original wire when it contains rules because the temporary serializer cannot recreate the protobuf payload.

Remaining gates

This PR remains a draft until these gates are complete.

Checks

  • Core and React Native type checks
  • Targeted ESLint and formatting checks
  • 11 targeted Jest suites
  • 175 targeted tests
  • 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
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 31018a5 to c804067 Compare August 3, 2026 15:45
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from b612833 to 87ae73c Compare August 3, 2026 15:45
Comment on lines +75 to +77
isEmptyContext(_context)
? undefined
: toDdContextPreservingTargetingKey(_context),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This converts an empty effective OpenFeature context ({}) to undefined, causing FlagsClient to reuse its stored/embedded context, and this is being removed in #1359, right?

@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from c804067 to 0014b99 Compare August 7, 2026 01:00
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from 87ae73c to 6e3fcfe Compare August 7, 2026 01:00
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 0014b99 to 8a11853 Compare August 7, 2026 12:24
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from 6e3fcfe to 2bdc125 Compare August 7, 2026 12:24
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 8a11853 to d4d92d0 Compare August 10, 2026 18:54
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR3 branch from 2bdc125 to c261929 Compare August 10, 2026 18:54
@datadog-prod-us1-5

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/dd-sdk-reactnative | test:native-ios-newarch   View in Datadog   GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c261929 | Docs | Datadog PR Page | Give us feedback!

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.

2 participants