Skip to content

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

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

btthomas wants to merge 18 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 consumes the prepared protobuf object from configuration.rules.response directly.
  • It keeps a valid branch when its sibling is invalid.
  • It uses matching precomputed data first.
  • It uses valid rules data second.
  • It returns the applicable configuration error when no path is usable.
  • It preserves missing and empty targeting keys as different values.
  • 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.
  • 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.
  • Native code applies doLog to the exposure event.
  • The SDK supplies an empty extraLogging object because the native bridge still requires it.
  • Error and unmatched default results are not tracked.

TODO status

This PR adds no new TODO(FFL-2837) marker. It inherits the two PR1 follow-ups for regular-expression limits and the future peer-dependency minimum.

Checks

  • Core TypeScript checks
  • Changed-file ESLint and formatting checks
  • Full core Jest suite

@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

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0a88b52 | Docs | View more details | 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
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from dcd5e65 to 4df01a4 Compare August 11, 2026 20:09
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from d4d92d0 to 7b38d92 Compare August 11, 2026 20:09
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from 4df01a4 to 965b0fb Compare August 18, 2026 12:39
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 7b38d92 to 7e4aca2 Compare August 18, 2026 12:39
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from 965b0fb to 98b4fd3 Compare August 20, 2026 16:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 7e4aca2 to a678a7e Compare August 20, 2026 16:37
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from 98b4fd3 to fb29b11 Compare September 15, 2026 13:56
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from a678a7e to 1f6c1d3 Compare September 15, 2026 13:56
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR1 branch from fb29b11 to 705762d Compare September 18, 2026 13:50
@btthomas
btthomas force-pushed the blake.thomas/FFL-2837-PR2 branch from 7ea2311 to 0a88b52 Compare September 18, 2026 13:50

This branch has not been deployed

No deployments
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