feat(openfeature): support semantic version conditions - #9022
Conversation
Add support for the six UFC semantic-version condition operators: SEMVER_EQ, SEMVER_NEQ, SEMVER_LT, SEMVER_LTE, SEMVER_GT, and SEMVER_GTE. The evaluator validates semantic-version comparands from Remote Config and matches the Rust semver evaluator's ordering behavior, including prerelease versions and build metadata. Build metadata is validated but intentionally ignored for precedence comparison. Port of dd-trace-go PR #5128. System test fixtures applied from DataDog/ffe-system-test-data evaluation-cases: - test-case-semver-comparison-flag.json (13 cases) - test-case-semver-validation-flag.json (9 cases)
BenchmarksBenchmark execution time: 2026-08-12 20:37:29 Comparing candidate commit de7e3f1 in PR branch Found 1 performance improvements and 1 performance regressions! Performance is the same for 70 metrics, 0 unstable metrics, 66 known flaky benchmarks, 60 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9022) and master. ✅ No regressions detected |
There was a problem hiding this comment.
Pull request overview
Adds semantic-version targeting to the OpenFeature evaluator.
Changes:
- Implements SemVer parsing, validation, and precedence comparison.
- Adds six
SEMVER_*condition operators with eager configuration validation. - Adds unit and bundled fixture coverage for comparison and validation behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tracer/src/Datadog.Trace/FeatureFlags/SemVer.cs |
Implements SemVer parsing and comparison. |
tracer/src/Datadog.Trace/FeatureFlags/ParsedSemVer.cs |
Defines parsed version representation. |
tracer/src/Datadog.Trace/FeatureFlags/FeatureFlagsEvaluator.cs |
Evaluates SemVer conditions and reports invalid comparands. |
tracer/src/Datadog.Trace/FeatureFlags/Rcm/Model/ConditionOperator.cs |
Adds six SemVer operators. |
tracer/src/Datadog.Trace/FeatureFlags/Rcm/Model/ConditionConfiguration.cs |
Caches validated SemVer comparands. |
tracer/src/Datadog.Trace/FeatureFlags/Rcm/Model/ServerConfiguration.cs |
Validates flags and tracks invalid configurations. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/SemVerTests.cs |
Tests parsing, comparison, and evaluation. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/FeatureFlagsEvaluatorTests.Bundle.cs |
Supports reason assertions in shared fixtures. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/resources/config/flags-v1.json |
Adds SemVer test flags. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/resources/data/test-case-semver-comparison-flag.json |
Adds comparison scenarios. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/resources/data/test-case-semver-validation-flag.json |
Adds validation scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -0,0 +1,169 @@ | |||
| [ | |||
There was a problem hiding this comment.
FYI @andrewlock and I are working on linking our fixture files more automatically here: #8994
Depending on merge order we might need to resolve conflicts.
| // --------------------------------------------------------------------- | ||
| // ParseSemver tests (ported from Go TestParseSemver) | ||
| // --------------------------------------------------------------------- | ||
|
|
||
| [Theory] | ||
| [InlineData("0.0.0", 0UL, 0UL, 0UL, "")] | ||
| [InlineData("18446744073709551615.18446744073709551615.18446744073709551615", ulong.MaxValue, ulong.MaxValue, ulong.MaxValue, "")] | ||
| [InlineData("1.2.3-alpha.1", 1UL, 2UL, 3UL, "alpha.1")] | ||
| [InlineData("1.2.3-18446744073709551616", 1UL, 2UL, 3UL, "18446744073709551616")] | ||
| [InlineData("1.2.3+build.001", 1UL, 2UL, 3UL, "")] | ||
| [InlineData("1.2.3-alpha-1+build.001", 1UL, 2UL, 3UL, "alpha-1")] | ||
| public void TryParseValidVersions(string version, ulong major, ulong minor, ulong patch, string prerelease) |
There was a problem hiding this comment.
ideally all of these are case inside the ffe system test data. are they? if so these are duplicated but doesn't hurt to have some unit tests. if they are no please add upstream.
There was a problem hiding this comment.
Sent you a DM about this
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary of changes
Add support for the six UFC semantic-version condition operators: SEMVER_EQ, SEMVER_NEQ, SEMVER_LT, SEMVER_LTE, SEMVER_GT, and SEMVER_GTE.
The evaluator validates semantic-version comparands from Remote Config and matches the Rust semver evaluator's ordering behavior, including prerelease versions and build metadata. Build metadata is validated but intentionally ignored for precedence comparison.
Port of dd-trace-go PR #5128. System test fixtures applied from DataDog/ffe-system-test-data evaluation-cases:
Reason for change
To support semantic version targeting to meet compatibility with existing Client SDK functionality.
Implementation details
SemVer.cs/ParsedSemVer.cs— Parser and comparator ported from Go'sopenfeature/semver.go. Handlesmajor.minor.patch(uint64-bounded), prerelease identifiers (arbitrarily large numeric), and build metadata (validated, not retained for precedence).FeatureFlagsEvaluator.cs— AddedEvaluateSemverCondition()for the sixSEMVER_*operators. Callsconfig.Validate()in the constructor for eager comparand parsing. ReturnsPARSE_ERRORfor flags with invalid comparands.ConditionConfiguration.cs— Replaced lazyGetSemverComparand()with eagerTryPreparseSemverComparand()called during config validation.ServerConfiguration.cs— AddedValidate()that pre-parses SemVer comparands and tracks invalid flags inInvalidFlags.Merge()resets validation state.ConditionOperator.cs— Added the sixSEMVER_*enum values.Comparands are parsed eagerly at config load time (matching Go PR #5128), not lazily during evaluation. This enables fail-fast detection of invalid comparands and returns
PARSE_ERRORinstead of throwing during evaluation.Test coverage
SemVerTests.cs(parsing, comparison, all six operators, invalid comparands)Other details