Skip to content

feat!: fractional bucketing improvements#1909

Open
toddbaert wants to merge 3 commits intomainfrom
feat/fractional-enhancements
Open

feat!: fractional bucketing improvements#1909
toddbaert wants to merge 3 commits intomainfrom
feat/fractional-enhancements

Conversation

@toddbaert
Copy link
Copy Markdown
Member

@toddbaert toddbaert commented Mar 20, 2026

High-precision and nested fractional

This is a coordinated feature across flagd and all flagd providers.

  • fractional now supports up to max-int32 total weight and 1/max-int32 resolution as described in the high-precision fractional bucketing ADR
  • fractional now supports computed (nested JSONLogic) variants and weights as described in the fractional ADR
  • Includes e2e tests from the flagd-testbed v3.1.0...v3.4.0 to validate consistent fractional bucketing across all provider implementations
  • ⚠️ Pseudorandom hash assignments will change with this release due to changes in the hashing algorithm; update flagd and your providers to ensure fractional assignment is consistent across all workloads

Related PRs

Component PR
flagd #1909
java-sdk-contrib open-feature/java-sdk-contrib#1740
js-sdk-contrib open-feature/js-sdk-contrib#1501
python-sdk-contrib open-feature/python-sdk-contrib#373
dotnet-sdk-contrib open-feature/dotnet-sdk-contrib#622
flagd-schemas open-feature/flagd-schemas#207

Warning
@toddbaert will coordinate the release across flagd and all providers. Do not merge without coordination.
@toddbaert will update the RPC mode tests accordingly once the associated flagd PR is merged and an up-to-date flagd-testbed image is available.

@toddbaert toddbaert requested review from a team as code owners March 20, 2026 19:06
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 20, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 20, 2026

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 5ac713a
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/69cbdf754a9b200008f4329f

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the fractional evaluation feature by increasing its precision and adding support for nested JSONLogic, providing more flexibility in flag configurations. It also includes dependency updates and integration test improvements to ensure the reliability of the changes.

Highlights

  • Fractional Evaluation Precision: Increased the total weight and resolution of fractional evaluation, now supporting up to max-int32 total weight and 1/max-int32 resolution.
  • Nested Fractional Evaluation: Enabled computed (nested JSONLogic) variants and weights within fractional evaluations, allowing for more dynamic flag configurations.
  • Dependency Updates: Updated the github.com/diegoholiveira/jsonlogic/v3 dependency to v3.9.0, incorporating the latest features and fixes.
  • Integration Testing: Refactored integration tests to run independently of the rest of the code, ensuring more reliable end-to-end testing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The fractional evaluator was updated to support boolean, numeric, and nil variants, and also nested JSON logic. The totalWeight and variant weight are now int32 instead of int to support larger weight values. The hashing of the value to distribute is now done in the Evaluate function rather than in the distributeValue function. The test suite was updated to use constants for email addresses and other string literals to improve readability and maintainability. The test suite was updated to add tests for nested JSON logic.


func (fe *Fractional) Evaluate(values, data any) any {
valueToDistribute, feDistributions, err := parseFractionalEvaluationData(values, data)
valueToDistribute, feDistributions, err := parseFractionalEvaluationData(values, data, fe.Logger)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The fe.Logger is passed as an argument to parseFractionalEvaluationData. This is good for testability and dependency injection.

Comment on lines +51 to +52
hashValue := uint32(murmur3.StringSum32(valueToDistribute))
return distributeValue(hashValue, feDistributions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The hashing of the valueToDistribute is now done in the Evaluate function rather than in the distributeValue function. This centralizes the hashing logic and makes the distributeValue function more focused on its core task.

return ""
}

bucket := (uint64(hashValue) * uint64(feDistribution.totalWeight)) >> 32
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This calculation is the core of the high-precision fractional bucketing. It uses integer arithmetic to map the hash value to a bucket within the range [0, totalWeight).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Weird that gemini seems to just be making a lot of these observational comment lately.

@toddbaert toddbaert force-pushed the feat/fractional-enhancements branch from 4f7cc84 to f4ea487 Compare March 30, 2026 15:07
* fractional now supports up to max-int32 total weight, and 1/max-int32
  resolution
* fractional now supports computed (nested JSONLogic) variants and
  weights

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert force-pushed the feat/fractional-enhancements branch from 94a3905 to 8d04a4f Compare March 30, 2026 19:06
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@sonarqubecloud
Copy link
Copy Markdown

@toddbaert toddbaert changed the title feat: high-precision and nested fractional feat!: fractional bucketing improvements Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants