Skip to content

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

Draft
btthomas wants to merge 11 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 11 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 accepts each context when valid rules are available.
  • It preserves a missing targeting key.
  • It selects the evaluation path for each resolution.
  • It uses matching precomputed data first.
  • It uses valid rules data second.
  • It maps rules results to FlagDetails.
  • It converts real assignments to an internal TrackableAssignment.
  • It keeps online and precomputed behavior unchanged.

Reason

A mixed configuration can contain precomputed assignments for one context and rules for other contexts. FlagsClient must select the path when it resolves each flag. This check prevents the SDK from using a mismatched precomputed assignment.

Result behavior

  • A flag that the upstream parser removes returns FLAG_NOT_FOUND.
  • A missing targeting key stays missing. An empty targeting key is a real value.
  • Integer and numeric rules variations both use the OpenFeature type number.
  • The fake engine stays as the permanent boundary for path-selection tests.

Tracking

A real rules assignment uses the existing native assignment bridge. The bridge reports the assignment through the same Datadog path as online and precomputed assignments.

  • 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.
  • The current mobile bridge does not accept the split serial ID or evaluator timestamp.

Error, disabled, unmatched default, no-variant default, type-mismatch, and missing-flag results are not tracked.

Temporary upstream code

This PR adds one TODO(FFL-2837) marker. It keeps the temporary rulesBased compatibility shape until a published flagging-core release contains FlagsConfiguration.rules.response from openfeature-js-client#344.

PR1 contains the other upstream compatibility markers. The targeting-key policy and the deterministic fake are not temporary.

User impact

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

The provider does not pass its effective resolution context in this PR. PR3 adds that connection and the customer documentation.

Checks

  • yarn tsc --noEmit -p packages/core/tsconfig.json
  • Targeted ESLint for the changed TypeScript files
  • 103 flags 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
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