Repository navigation
feat(Flag Dependency): Evaluate flags that depend on other flags in local evaluation - #205
Open
linear-code[bot] wants to merge 2 commits into
Open
linear-code[bot] wants to merge 2 commits into
linear-code[bot] wants to merge 2 commits into
Conversation
…ocal evaluation Port flagsmith-engine#343 to the .NET engine. Segment conditions reading `$.flags.<feature>.enabled`, `.value` or `.variant` now resolve that flag's evaluated result lazily, including transitive chains. Flags in a dependency cycle are reported with the `ERROR; code=CIRCULAR_DEPENDENCY` reason. Flag results now carry the selected multivariate `variant`, mapped from the option key in the environment document, so dependencies on variants work. Bump engine-test-data to v3.11.0, which adds the flag dependency cases. Generated with [Linear](https://linear.app/flagsmith/agent-session/be5fe950-2490-482f-91fa-7a20fa7fdec3) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
…hmarks Segment matches resolved for flag dependencies are now reused by the main segment loop instead of being evaluated again, and the dependency resolver only allocates its state once a condition reads a flag. Adds a BenchmarkDotNet project comparing engine revisions over synthetic environments and the engine-test-data cases. Generated with [Linear](https://linear.app/flagsmith/agent-session/be5fe950-2490-482f-91fa-7a20fa7fdec3) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
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.
Segments can now be conditioned on another flag's evaluated result, e.g. "enable
checkoutfor whoever hasbeta_accesson". Edge API already does this through flagsmith-engine#343. Until now the .NET engine ignored these conditions, so local evaluation served the wrong flags for any project that uses them. This PR ports the same behaviour to the .NET engine.Changes
$.flags.<feature>.enabled,.valueor.variantread that flag's evaluated result, including chains of dependencies. Flags are resolved only when a condition reads them.ERROR; code=CIRCULAR_DEPENDENCY.$.are read as paths;$['flags']…is treated as a trait name, same as the reference engine.variant(the variant key,control, or null). Local evaluation reads the key from the environment document, so.variantdependencies work there too.STATICreason change (flagsmith-engine#347). Renovate deps: update dependency flagsmith.enginetest/enginetestdata to v3.12.1 #198 will need that change ported before it can pass.Override precedence keeps this SDK's existing tie-break (on equal priority, the segment seen last wins). The reference engine picks the first seen. That difference is older than this PR and left unchanged here.
Performance
A new
Flagsmith.Engine.Benchmarksproject (BenchmarkDotNet 0.15.8) compares this branch against baseline e2c5320, the commit before flag dependency, using the same workloads and the same engine-test-data v3.11.0 inputs. The synthetic environment has 200 features (20 multivariate) and 50 segments with nested trait rules. The dependency workload adds 10 prerequisite flags and 10 segments reading$.flags.prerequisite_N.enabled; its control repeats the prerequisite trait rules instead and produces identical flags. Commands are in the project README:Median time per evaluation, range across 3 baseline runs and 2 branch runs, interleaved. Allocation per evaluation is deterministic.
variantfield on each of the 200 flag results, though I haven't measured that separately.GetIdentityFlags, .NET 6–9, or other hardware.Contributes to https://linear.app/flagsmith/issue/SDK-7/enable-flag-dependency-in-the-net-server-side-sdk
Review effort: 4/5