Skip to content

feat(fractional): add nested fractional expression gherkin scenarios#345

Merged
toddbaert merged 2 commits intomainfrom
feat/nested-fractional
Mar 18, 2026
Merged

feat(fractional): add nested fractional expression gherkin scenarios#345
toddbaert merged 2 commits intomainfrom
feat/nested-fractional

Conversation

@aepfli
Copy link
Copy Markdown
Member

@aepfli aepfli commented Mar 16, 2026

Summary

Adds gherkin test coverage for nested JSON Logic expressions as bucket variant names in the fractional operator — tracking open-feature/flagd-evaluator#30 and open-feature/flagd-evaluator#31.

New flag definitions

  • fractional-nested-if-flag — variant name is an {"if": [...]} expression resolved from context
  • fractional-nested-var-flag — variant name is a {"var": "..."} expression read from context

New scenarios

Both tagged @fractional @fractional-nested:

  • Fractional operator with nested if expression as variant name
  • Fractional operator with nested var expression as variant name

Transition support

The dedicated @fractional-nested tag lets providers opt out during their migration period:

-t 'not @fractional-nested'

Verification

All rows verified against the Rust flagd-evaluator gherkin test suite (worktree feat/nested-fractional).

@aepfli aepfli requested a review from a team as a code owner March 16, 2026 10:58
@gemini-code-assist
Copy link
Copy Markdown

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 significantly expands the test suite for the fractional operator by introducing scenarios that validate its functionality when bucket variant names are derived from nested JSON Logic expressions. This ensures the evaluator correctly handles dynamic variant resolution, improving the robustness and reliability of flag targeting.

Highlights

  • Enhanced Fractional Operator Testing: Added comprehensive Gherkin test coverage for the fractional operator to validate its behavior with nested JSON Logic expressions used as bucket variant names.
  • New Flag Definitions: Introduced two new flag definitions, fractional-nested-if-flag and fractional-nested-var-flag, in flags/custom-ops.json to demonstrate and test dynamic variant name resolution.
  • New Gherkin Scenarios: Created two new Gherkin scenarios, "Fractional operator with nested if expression as variant name" and "Fractional operator with nested var expression as variant name", to specifically test the new flag definitions.
  • Transition Support: Implemented a dedicated @fractional-nested tag to allow providers to opt out of these new tests during their migration period.
Changelog
  • flags/custom-ops.json
    • Added fractional-nested-if-flag definition, using an if expression for variant name.
    • Added fractional-nested-var-flag definition, using a var expression for variant name.
  • gherkin/targeting.feature
    • Added "Fractional operator with nested if expression as variant name" scenario.
    • Added "Fractional operator with nested var expression as variant name" scenario.
Activity
  • No explicit activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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

This pull request adds Gherkin test scenarios for nested JSON Logic expressions within the fractional operator, which is a valuable addition for ensuring evaluator correctness. The new flag definitions in flags/custom-ops.json and the corresponding scenarios in gherkin/targeting.feature are well-structured. I've suggested one improvement to enhance the test coverage for the fractional-nested-var-flag scenario by including cases where the resolved variant is invalid or missing, to ensure robust fallback behavior.

@aepfli aepfli changed the title test(fractional): add nested fractional expression gherkin scenarios feat(fractional): add nested fractional expression gherkin scenarios Mar 18, 2026
aepfli and others added 2 commits March 18, 2026 10:22
Add two new flag definitions and @fractional-nested tagged scenario
outlines to validate nested JSON Logic expressions as bucket variant
names in the fractional operator.

New flags:
- fractional-nested-if-flag: bucket variant name is an if expression
  that resolves to 'premium' or 'standard' based on context 'tier'
- fractional-nested-var-flag: bucket variant name is a var expression
  that reads 'color' from evaluation context

New scenarios (tagged @fractional @fractional-nested):
- 'Fractional operator with nested if expression as variant name'
- 'Fractional operator with nested var expression as variant name'

The @fractional-nested tag allows providers to exclude these scenarios
during the transition period before their implementation supports
nested expressions:

  -t 'not @fractional-nested'

All rows verified against the Rust flagd-evaluator test suite.

Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: add two rows to the nested-var scenario that
exercise fallback behavior when the resolved variant name is not
present in the flag's variants map.

  | jon@company.com | yellow | fallback |  (variant not in map → error → caller default)
  | jon@company.com |        | fallback |  (empty string → not in map → error → caller default)

Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@toddbaert toddbaert merged commit 267a1bf into main Mar 18, 2026
3 checks passed
aepfli added a commit that referenced this pull request Mar 30, 2026
…rkin suite

Adds evaluator counterparts for the four @fractional-nested scenarios that
were added to the SDK-level gherkin in #345 and subsequent commits but never
mirrored to the evaluator suite:

- Nested if expression as variant name (fractional-nested-if-flag)
- Nested var expression as variant name (fractional-nested-var-flag)
- Nested if expression as weight (fractional-nested-weight-flag)
- Fractional operator used as a boolean condition (fractional-as-condition-flag)

All scenarios are tagged @fractional-nested so evaluator implementations can
opt out during migration with -t 'not @fractional-nested'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
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