← Back to Pull requests

feat(flags): route split features and share exposure decisions #1291

Closed
unknown closed this pull request without merging on Nov 13, 2026 17:27 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 15:46 UTC
Author

What and why?

Precomputed assignments can carry features for the selected split. Each feature has a key, a value (string, number or boolean) and destinations (HOOK, EXPOSURE, EVALUATION). This PR uses them and lets applications record exposures in their own data store, with the same deduplication that the SDK uses for Datadog.

  • Parse features leniently. A malformed list or entry is skipped and never fails the flag. On a repeated key, the first valid entry wins. Unknown destinations are kept but ignored, with one warning for each distinct value (64 at most).

  • Persist features with stored assignments.

  • Put HOOK features in flag metadata as __dd_feature.<key>. This prefix is the only public metadata contract. EXPOSURE and EVALUATION features use internal prefixes.

  • Add EXPOSURE features to exposure events as a flat features object. They are not part of the exposure cache entry.

  • Add EVALUATION features to the evaluation-count bucket key and to each row.

  • Add a public ExposureHook for OpenFeature. Its callback receives every completed evaluation from DatadogOpenFeatureProvider with isExposure, isCacheHit, shouldSend, the flag key, variant, allocation key, targeting key, evaluation context and HOOK features. A failing callback does not affect the evaluation.

  • Make one exposure decision for each successful evaluation. The Datadog send and ExposureHook share it.

  • With trackExposures: false, the SDK sends no exposures, but the exposure cache still records, so ExposureHook gets correct decisions.
  • Behaviour changes:

  • OpenFeature: the provider records and sends an exposure in its own finallyAfter hook, only when the whole evaluation succeeded. Before, it sent the exposure at resolve time, also when a later hook failed.

  • OpenFeature: a direct call to a DatadogOpenFeatureProvider.resolve...Value method, outside an OpenFeature client, records no exposure.

  • OpenFeature results of allocations that log exposures carry internal __dd_ metadata keys.

  • DatadogFlagsClient.get...Details still records and sends exposures immediately.

  • EVALUATION features are attached only to successful evaluation rows; error rows, such as a type mismatch, carry none.
  • How?

    The provider registers its own OpenFeature hook. Its before stage opens a frame for the evaluation, the provider's resolve method attaches the pending exposure to that frame, and its finallyAfter stage records the exposure only when the details have no error code. The verdict is attached to the evaluation details instance, which OpenFeature passes to every finallyAfter hook, so ExposureHook reads the same verdict.

    Verified in openfeature_dart_client_sdk 0.0.1: provider hooks run last in before and first in after, error and finallyAfter; a failing before or after hook replaces the details with error details before finallyAfter; exceptions from finallyAfter hooks are caught by the SDK. This version has no multi-provider; a provider that wraps this provider without running its hooks records no exposures, as in the Go, browser and Android SDKs.

    Tests: unit tests for parsing, routing, persistence and warnings, and end-to-end tests with an isolated OpenFeatureAPI and a mock HTTP client, on the VM and in Chrome. Each new test was checked by breaking the code under test. datadog_flags_flutter (re-exports and README only) was not run locally because Flutter is not installed; CI covers it.

    Jira: EX-4007

    Review checklist

  • This pull request has appropriate unit and / or integration tests

  • This pull request references a Github or JIRA issue
  • Diff: 456 lines (+342 / -114) across 5 files Reviewer: fuzzybinary Review duration: 5860m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 456 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1291"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.0% · Safe to merge
    18.0%