Skip to content

feat(flags): evaluate dynamic offline rules (FFL-2837 PR2) - #1347

Draft
btthomas wants to merge 13 commits into
blake.thomas/FFL-2837-PR1from
blake.thomas/FFL-2837-PR2
Draft

feat(flags): evaluate dynamic offline rules (FFL-2837 PR2)#1347
btthomas wants to merge 13 commits into
blake.thomas/FFL-2837-PR1from
blake.thomas/FFL-2837-PR2

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 (feat(flags): evaluate dynamic offline rules (FFL-2837 PR2) #1347) <- you are here
  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 dynamic and mixed offline evaluation to FlagsClient.

  • It stores precomputed and rules branches independently.
  • It keeps a valid branch when its sibling is invalid.
  • It preserves branch and flag parse errors.
  • It accepts each context when valid rules are available.
  • It preserves a missing targeting key.
  • It uses matching precomputed data first.
  • It uses valid rules data second.
  • It returns the applicable configuration error when no path is usable.
  • It maps rules results to FlagDetails.
  • It converts real assignments to TrackableAssignment.
  • It keeps online and valid precomputed behavior unchanged.

Result behavior

  • A malformed flag in matching precomputed data returns PARSE_ERROR before rules fallback.
  • A malformed reached rules flag returns PARSE_ERROR.
  • An absent flag returns FLAG_NOT_FOUND.
  • A missing targeting key stays missing.
  • An empty targeting key is a real value.
  • Integer and numeric rules variations use the OpenFeature type number.
  • An unsafe integer returns PARSE_ERROR instead of an imprecise number.

Tracking

A successful rules assignment uses the existing native assignment bridge.

  • The SDK calls the bridge for each real assignment.
  • A false doLog value does not stop the bridge call.
  • Native code applies doLog to the exposure event.
  • The SDK supplies an empty extraLogging object because the current Android bridge requires it.
  • Error and default results are not tracked.

Temporary upstream code

This PR adds one TODO(FFL-2837) marker. The stacked PR2 branch contains 16 markers.

The new marker keeps the temporary rulesBased compatibility shape until a published flagging-core release contains openfeature-js-client#344 through 939da97 and the required SHA digest validation follow-up.

openfeature-js-client#336 is currently at 6d3d6a4. Its latest change only restacks it on PR #344. Its valid-sibling and error precedence remain the parity reference.

User impact

The existing offline client can evaluate rules after a context change. It does not fetch data. Matching precomputed data still has priority.

PR3 connects the provider resolution context to this path and adds customer documentation.

Checks

  • Core type checks
  • Targeted ESLint and formatting checks
  • 7 targeted Jest suites
  • 125 targeted tests

@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from bb7ad12 to d8dd76f Compare July 27, 2026 19:53
@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-PR1 branch from df96e05 to a50f71d Compare July 28, 2026 18:55
@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-PR1 branch from a50f71d to 31cc62b Compare July 29, 2026 14:27
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from a725eb5 to 45a8242 Compare July 29, 2026 14:27
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from 31cc62b to f614832 Compare July 30, 2026 13:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 45a8242 to 0cc9e56 Compare July 30, 2026 13:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from f614832 to 78d60c2 Compare July 31, 2026 13:58
@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-PR1 branch from 78d60c2 to 4902bc1 Compare August 3, 2026 15:45
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 31018a5 to c804067 Compare August 3, 2026 15:45
Comment on lines 536 to +537
if (!flag) {
return {
key,
value: defaultValue,
reason: 'ERROR',
errorCode: 'FLAG_NOT_FOUND'
};
return this.errorDetails(key, defaultValue, 'FLAG_NOT_FOUND');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the PR description

A flag that the upstream parser removes returns FLAG_NOT_FOUND

Once we consume the parser from DataDog/openfeature-js-client#344, malformed known flags should be preserved in precomputed.flagErrors and resolve to the coded default with PARSE_ERROR, matching core/browser. I see this PR already handles flagErrors before this fallback. Can you update the description and add an integration test using the upstream parser output?

Comment on lines 42 to 45
export type ConfigurationErrorCode =
| 'INVALID_CONTEXT'
| 'PROVIDER_NOT_READY'
| 'GENERAL';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this should include PARSE_ERROR and should map to OpenFeature’s ParseError. Reserve GENERAL for failures that are more unexpected and harder to classify

@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-PR1 branch from 59cbac3 to 8dc8c27 Compare August 7, 2026 12:23
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 0014b99 to 8a11853 Compare August 7, 2026 12:24
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 7, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/dd-sdk-reactnative | test:build   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: d4d92d0 | 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
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 8a11853 to d4d92d0 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.

2 participants