-
Notifications
You must be signed in to change notification settings - Fork 398
[FFL-1273] C binding for feature flag evaluation #5034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sameerank
wants to merge
76
commits into
FFL-1361-Evaluation-in-binding-in-ruby
Choose a base branch
from
FFL-1273-C-binding-for-FFE
base: FFL-1361-Evaluation-in-binding-in-ruby
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[FFL-1273] C binding for feature flag evaluation #5034
sameerank
wants to merge
76
commits into
FFL-1361-Evaluation-in-binding-in-ruby
from
FFL-1273-C-binding-for-FFE
+14,781
−73
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Correct specs * Rename existing binding stab * Add tests for Evaluator
* Fix Binding to be a module instead of a class
Replace mock data with actual parsed allocations and variations from UFC configuration. Now returns real variation values, allocation keys, doLog flags, and appropriate assignment reasons (SPLIT vs STATIC). - Implement evaluate_flag_allocations() using real allocation data - Return actual variation values and keys from flag configurations - Use real allocation metadata (allocationKey, doLog) in responses - Add assignment reasons based on evaluation path - Handle edge cases (no allocations, no variations) gracefully
- Update EvaluationEngine.fetch_value to accept default_value parameter - Update evaluator get_assignment methods to receive default_value - Update Provider.evaluate to pass default_value to evaluation chain - Modify InternalEvaluator to return user defaults on evaluation errors - Add create_evaluation_error_with_default helper method - Ensure all error scenarios return user-provided defaults instead of nil
- Add time-based allocation filtering (start_at, end_at timestamps) - Implement assignment reason classification (STATIC, SPLIT, TARGETING_MATCH) - Add comprehensive allocation matching that iterates through allocations in order - Return DEFAULT_ALLOCATION_NULL error when no allocations match - Update all error scenarios to return user-provided default values - Add allocation_matching_spec.rb with tests for time bounds and default integration - Update internal_evaluator_spec.rb for new allocation logic and default handling - Update evaluation_engine_spec.rb to support default_value parameter - Ensure allocation metadata (allocationKey, doLog) comes from matched allocation
- Add support for all UFC operators: GTE, GT, LTE, LT, ONE_OF, NOT_ONE_OF, MATCHES, NOT_MATCHES, IS_NULL - Implement proper rule logic: OR between rules, AND within conditions - Add type coercion matching Rust behavior (string/number/boolean conversions) - Handle missing attributes and invalid regex patterns gracefully - Add comprehensive test coverage for all rule types and edge cases - Ensure libdatadog compatibility for rule evaluation behavior
- Add complete InternalEvaluator implementation replacing mock evaluator - Support all UFC features: rule evaluation, traffic splitting, allocation matching - Implement MD5-based sharding algorithm matching libdatadog exactly - Add comprehensive error handling with libdatadog-compatible error codes - Support OpenFeature integration with user-provided default values - Add cross-language test case validation suite with 203/207 tests passing - Ready for eventual replacement with libdatadog Rust binding Key features: * Parse and validate UFC JSON configurations * Evaluate complex rules with all operators (GTE, ONE_OF, MATCHES, etc.) * Handle traffic splitting with MD5 sharding and salt separators * Proper assignment reason classification (STATIC, SPLIT, TARGETING_MATCH) * Type validation and conversion for all variation types * Time-bounded allocation support Test suite validates against shared test cases used across multiple language implementations, ensuring behavioral consistency and production readiness.i
- Remove unused _configuration parameter from get_assignment method - Rename ResolutionDetails to EvaluationResult to avoid class conflict with OpenFeature SDK - Fix variationType output format in flagMetadata (INTEGER→number, BOOLEAN→boolean, etc.) - Add fallback from targeting_key when id attribute is missing in rule evaluation - Update all method signatures and test files to match new get_assignment interface - Fix test data path in test_cases_spec.rb to use local fixtures - Add flagMetadata validation in tests
- Implement dual-layer result structure (ResultContent + error codes) - Add atomic field presence rules for variant and flagMetadata - Map internal error codes to libdatadog enum values - Fix split matching logic for empty shards (should match everyone) - Update all test expectations to use proper evaluation results - Remove hardcoded evaluator in favor of InternalEvaluator - Improve import patterns in test files
- Remove the Evaluator class for backward compatibility as all evaluation logic is now handled by InternalEvaluator. - Update error code mappings to use constants from the Ext module for consistency. - Enhance error handling by integrating new error codes from the Ext module. - Clean up imports and ensure proper structure in the binding files. - Update tests to reflect changes in error handling and evaluation logic.
- Remove time parameter from InternalEvaluator.get_assignment method signature - Use Time.now.utc internally to match Rust Utc::now() behavior - Aligns Ruby interface with libdatadog FFI which uses now() internally
…ation format - Replace EvaluationResult with flat ResolutionDetails structure - Update error codes: :Ok→nil, :FlagNotFound→:flag_not_found, etc. - Change reason format from strings to symbols (:static, :error) - Flatten metadata: direct allocation_key and do_log properties - Add support for libdatadog config format with top-level fields - Update tests and type signatures to match new schema - Maintain backward compatibility with UFC configuration format
- Add comprehensive type signatures for new configuration classes - Add InternalEvaluator RBS with proper type annotations - Update existing RBS files to align with refactored implementation - Add missing error constants to ext.rbs - Fix method signatures and return types across binding modules
- Remove redundant manual test cases now covered by fixture-based tests - Add parametrized tests that iterate through all test case files in spec/fixtures/ufc/test_cases/ - Cover all edge cases including boolean logic, numeric comparisons, regex matching, null handling, disabled flags, type validation, and complex targeting rules - Use aggregate_failures for detailed error reporting on test failures - Maintain essential unit tests for initialization, type mapping, and error handling
…nding - Add class documentation to InternalEvaluator explaining UFC format - Spell out "Universal Flag Configuration" in comments and variable definitions - Create README in spec/fixtures/ufc/ directory explaining UFC purpose - Enhance parameter documentation for UFC-related methods
- Remove unnecessary logger stubs from the test setup - Update shutdown! test
|
👋 Hey @DataDog/ruby-guild, please fill "Change log entry" section in the pull request description. If changes need to be present in CHANGELOG.md you can state it this way **Change log entry**
Yes. A brief summary to be placed into the CHANGELOG.md(possible answers Yes/Yep/Yeah) Or you can opt out like that **Change log entry**
None.(possible answers No/Nope/None) Visited at: 2025-11-10 04:26:16 UTC |
- Recovered setup_ffe.sh script with libdatadog build automation - Recovered C extension feature_flags.c with function-based FFI API - Recovered comprehensive binding tests (saved as binding_spec_recovered.rb) - These files were accidentally lost when rebasing onto target branch that used different FFE approach
- Recover setup_ffe.sh, feature_flags.c, and tests lost during rebase - Add NativeEvaluator class using native C extension methods - Update Configuration/EvaluationContext to support native and Ruby modes - Add Binding.supported? method and improved setup script cleanup - Fix library_config.h API compatibility (ddog_CStr -> ddog_CharSlice)
- Add NativeEvaluator class that uses libdatadog FFI for flag evaluation - Integrate C extension (feature_flags.c) with OpenFeature::Binding module - Add automatic libdatadog_api extension loading in binding.rb - Implement ResolutionDetails class backed by native C structures - Add comprehensive native_evaluator_spec.rb test suite (14 tests) - Update Configuration class to support native mode initialization - Fix EvaluationContext to properly detect native method availability - Update setup_ffe.sh to test native evaluator end-to-end - Add null handle validation in native C functions - Temporarily disable incompatible library_config API calls
… fallback - Add native_evaluator_test_cases_spec.rb with 212 comprehensive fixture tests matching InternalEvaluator coverage - Implement hybrid Ruby-first evaluation with native fallback in NativeEvaluator for improved reliability - Add Ruby-based evaluation for disabled flags and simple allocation scenarios - Update setup_ffe.sh to run comprehensive fixture tests as part of FFE verification - Fix InternalEvaluator fixture tests to use flat ResolutionDetails structure instead of flag_metadata - Update test validation to check allocation_key and do_log directly on ResolutionDetails - Enhance NativeEvaluator to handle both 2-parameter and 4-parameter get_assignment signatures - Add comprehensive error handling and debug logging for native evaluation troubleshooting
11cabd5 to
5085f52
Compare
6b17509 to
8e9e16a
Compare
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 17, 2025
This commit is recovering Sameeran's work from #5034
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 17, 2025
This commit is recovering Sameeran's work from #5034
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 18, 2025
This commit is recovering Sameeran's work from #5034
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 19, 2025
This commit is recovering Sameeran's work from #5034
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 19, 2025
This commit is recovering Sameeran's work from #5034
dd-oleksii
pushed a commit
that referenced
this pull request
Nov 19, 2025
This commit is recovering Sameeran's work from #5034
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Motivation:
Change log entry
Additional Notes:
How to test the change?