Skip to content

feat(meta_provider): add multi-provider evaluation strategies#102

Merged
josecolella merged 1 commit intomainfrom
feat/meta-provider-multi-strategy
Mar 16, 2026
Merged

feat(meta_provider): add multi-provider evaluation strategies#102
josecolella merged 1 commit intomainfrom
feat/meta-provider-multi-strategy

Conversation

@josecolella
Copy link
Collaborator

Summary

  • Adds FirstSuccessful, Comparison, and custom (Base) evaluation strategies to MetaProvider, reaching parity with the JS/Go SDK implementations
  • Refactors inline strategy logic into a Strategy pattern with extracted strategy objects
  • Adds missing fetch_integer_value and fetch_float_value methods
  • Adds track delegation to all wrapped providers that support it
  • Uses define_method to DRY up the 6 fetch methods
  • Bumps openfeature-sdk dependency to >= 0.4.0, < 1.0 and version to 0.1.0
  • Full backward compatibility maintained (strategy: :first_match default)

Resolves open-feature/ruby-sdk#212

Test plan

  • All 58 RSpec examples pass (up from 29)
  • 99.69% line coverage
  • RuboCop lint passes with 0 offenses
  • Backward compatibility: strategy: :first_match default behavior identical
  • Strategy unit tests for FirstMatch, FirstSuccessful, Comparison, and Base
  • Integration tests for integer/float types, track delegation, strategy acceptance

🤖 Jose's AI agent

Add FirstSuccessful, Comparison, and custom (Base) strategies to the
MetaProvider, reaching parity with the JS/Go SDK implementations.
Resolves open-feature/ruby-sdk#212.

Changes:
- Refactor inline strategy logic into Strategy pattern (Base, FirstMatch,
  FirstSuccessful, Comparison)
- Add missing fetch_integer_value and fetch_float_value methods
- Add track delegation to wrapped providers
- Use define_method to DRY up the 6 fetch methods
- Bump openfeature-sdk dependency to >= 0.4.0, < 1.0
- Bump version to 0.1.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
@gemini-code-assist
Copy link
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 significantly enhances the OpenFeature MetaProvider by introducing a robust strategy pattern for flag evaluation. It expands the provider's capabilities with new 'FirstSuccessful' and 'Comparison' strategies, alongside support for custom evaluation logic. The update also adds comprehensive support for integer and float flag types and ensures event tracking is delegated across all underlying providers, making the MetaProvider more powerful and aligned with other SDKs.

Highlights

  • New Evaluation Strategies: Introduced 'FirstSuccessful' and 'Comparison' evaluation strategies to the MetaProvider, achieving parity with other SDK implementations. Additionally, a 'Base' strategy class was added to enable custom strategy implementations.
  • Strategy Pattern Refactor: The inline strategy logic within the MetaProvider was refactored into a Strategy pattern, abstracting evaluation logic into separate strategy objects for better modularity and extensibility.
  • Expanded Flag Types: Added support for fetching integer and float flag values, completing the set of primitive types supported by the MetaProvider.
  • Track Delegation: Implemented delegation of 'track' calls to all wrapped providers that support this functionality, ensuring consistent event tracking across multiple providers.
  • Dependency and Version Updates: The 'openfeature-sdk' dependency was bumped to '>= 0.4.0, < 1.0', and the 'openfeature-meta_provider' version was updated to '0.1.0'.
  • Backward Compatibility: All changes maintain full backward compatibility, with ':first_match' remaining the default strategy.
Changelog
  • providers/openfeature-meta_provider/Gemfile.lock
    • Updated openfeature-sdk dependency to >= 0.4.0, < 1.0.
    • Updated openfeature-meta_provider version to 0.1.0.
  • providers/openfeature-meta_provider/README.md
    • Added support for Integer and Float flags.
    • Documented new FirstSuccessful and Comparison strategies.
    • Added guidance for creating custom strategies.
    • Documented track delegation.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider.rb
    • Refactored flag evaluation logic using a Strategy pattern.
    • Introduced FirstSuccessful and Comparison evaluation strategies.
    • Added fetch_integer_value and fetch_float_value methods.
    • Implemented track delegation to wrapped providers.
    • Used define_method to consolidate fetch methods.
    • Updated init and shutdown methods to handle providers that may not respond to them.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider/strategy/base.rb
    • Introduced Base class for defining custom evaluation strategies.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider/strategy/comparison.rb
    • Added Comparison strategy to evaluate all providers and check for unanimous results.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider/strategy/first_match.rb
    • Extracted FirstMatch strategy into its own class.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider/strategy/first_successful.rb
    • Added FirstSuccessful strategy to skip FLAG_NOT_FOUND errors but stop on others.
  • providers/openfeature-meta_provider/lib/openfeature/meta_provider_version.rb
    • Bumped gem version to 0.1.0.
  • providers/openfeature-meta_provider/openfeature-meta_provider.gemspec
    • Updated openfeature-sdk dependency to >= 0.4.0, < 1.0.
  • providers/openfeature-meta_provider/spec/openfeature/meta_provider/strategy/base_spec.rb
    • Added unit tests for Strategy::Base and custom strategy implementation.
  • providers/openfeature-meta_provider/spec/openfeature/meta_provider/strategy/comparison_spec.rb
    • Added unit tests for the Comparison strategy.
  • providers/openfeature-meta_provider/spec/openfeature/meta_provider/strategy/first_match_spec.rb
    • Added unit tests for the FirstMatch strategy.
  • providers/openfeature-meta_provider/spec/openfeature/meta_provider/strategy/first_successful_spec.rb
    • Added unit tests for the FirstSuccessful strategy.
  • providers/openfeature-meta_provider/spec/openfeature/meta_provider_spec.rb
    • Added integration tests for integer and float flag evaluation.
    • Added integration tests for track delegation.
    • Added tests for strategy acceptance and error handling.
Activity
  • No human activity 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.

@josecolella josecolella merged commit 9cce3f4 into main Mar 16, 2026
17 checks passed
@josecolella josecolella deleted the feat/meta-provider-multi-strategy branch March 16, 2026 17:37
Copy link
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

This pull request is an excellent improvement, refactoring the MetaProvider to use a Strategy pattern for evaluation. The introduction of FirstSuccessful and Comparison strategies, along with support for custom strategies, significantly enhances the provider's flexibility and brings it to parity with other OpenFeature SDKs. The code is much cleaner and more maintainable, especially with the use of define_method to DRY up the fetch logic. The added tests are comprehensive and the documentation updates are clear and helpful. I have one minor suggestion to improve the clarity of the new Comparison strategy.

Comment on lines +8 to +21
results = []
errors = []

providers.each do |provider|
details = fetch_block.call(provider)

if details.error_code.nil?
results << add_provider_metadata(details, provider)
else
errors << {provider: provider.metadata.name, error_code: details.error_code}
end
rescue => e
errors << {provider: provider.metadata.name, error_code: e.message}
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The errors array is initialized and populated, but its value is never used. This adds unnecessary complexity and can be confusing for future maintainers. The logic can be simplified by removing the errors array and only collecting successful results, while continuing to ignore providers that return an error or raise an exception.

          results = []

          providers.each do |provider|
            begin
              details = fetch_block.call(provider)
              results << add_provider_metadata(details, provider) if details.error_code.nil?
            rescue StandardError
              # Ignore providers that error or raise; they are excluded from comparison.
            end
          end

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.

Multi-Provider support

2 participants