Skip to content

feat(flags): add rules engine boundary (FFL-2837 PR1) - #1346

Draft
btthomas wants to merge 17 commits into
blake.thomas/FFL-2837from
blake.thomas/FFL-2837-PR1
Draft

feat(flags): add rules engine boundary (FFL-2837 PR1)#1346
btthomas wants to merge 17 commits into
blake.thomas/FFL-2837from
blake.thomas/FFL-2837-PR1

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 (feat(flags): add rules engine boundary (FFL-2837 PR1) #1346) <- you are here
  3. PR2: Dynamic offline evaluation (#1347)
  4. PR3: Provider API and documentation (#1348)

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

Summary

This PR adds the internal boundary for dynamic offline rule evaluation. It also makes precomputed context handling explicit.

  • It adds one adapter for the flagging-core rules engine.
  • It converts SDK contexts to flat rules contexts.
  • It preserves missing and empty targeting keys as different values.
  • It keeps valid sibling flags and configuration branches.
  • It preserves parser and evaluator errors.
  • It normalizes evaluator results and metadata.
  • It rejects unsafe integer conversion.
  • It rejects serialization when temporary rules data cannot round-trip.
  • It protects temporary lookup from reserved property names.
  • It treats an empty OpenFeature context ({}) as a real context.
  • It adds getPrecomputedContext(configuration) as a public temporary helper.
  • It returns a detached copy from getPrecomputedContext.
  • It updates precomputed examples to set the returned context explicitly.
  • It does not activate dynamic evaluation in FlagsClient. PR2 adds that behavior.

Reason

The React Native SDK must not implement a second production rules engine. The adapter keeps flagging-core details out of the SDK state machine. Tests can replace the adapter with a deterministic fake.

OpenFeature supplies {} for an unset or cleared global context. The provider cannot distinguish that state from an explicit {}. Therefore, the provider must treat {} literally. A context-specific precomputed customer must explicitly set the matching context.

Upstream contract

Published flagging-core version 2.0.2 does not contain the protobuf rules wire from openfeature-js-client#344. PR #344 is currently at 939da97.

The two latest PR #344 commits only refresh generated Node-server declarations and isolate browser tests. They do not change this React Native contract.

openfeature-js-client#353 adds the shared getPrecomputedContext helper. After publication, this PR must re-export the upstream helper and delete the local clone implementation.

After PR #344 is published, this PR must use the upstream parser and evaluator directly. It must not keep a local protobuf decoder or a second structural validator.

Temporary code

This PR contains 15 TODO(FFL-2837) markers:

  • Four markers cover temporary wire parsing and serialization.
  • Seven markers cover temporary rules types, validation, metadata, lookup, error storage, and the regular-expression policy.
  • Two markers cover the future canonical protobuf fixture tests.
  • Two markers cover migration to the shared getPrecomputedContext helper.

Keep the reserved-name and provider-bootstrap tests after the upstream migration. The fake rules engine is a permanent unit-test boundary.

User impact

This PR does not expose dynamic rules evaluation. It changes precomputed context behavior.

  • {} no longer restores the context that is stored in a precomputed configuration.
  • OpenFeature.clearContext() does not restore the stored configuration context.
  • getPrecomputedContext(configuration) returns a supported detached copy.
  • The application explicitly sets that context before provider registration.

Checks

  • Core and React Native type checks
  • Targeted ESLint and formatting checks
  • 5 targeted Jest suites
  • 72 targeted tests

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 31, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/dd-sdk-reactnative | test:native-ios   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: dcd5e65 | Docs | Datadog PR Page | Give us feedback!

@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from 8dc8c27 to dcd5e65 Compare August 10, 2026 18:54
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