Repository navigation
feat(Flag Dependency): Evaluate flags that depend on other flags in local evaluation - #67
Open
linear-code[bot] wants to merge 2 commits into
Conversation
…ocal evaluation Port flagsmith-engine's context evaluator, including flag dependency, and run identity flags through it. Bump engine-test-data to v3.12.1 and run all of its test cases. Generated with [Linear](https://linear.app/flagsmith/agent-session/51c26f09-5fe3-44a8-8e3d-be2cf9ac50ff) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
Split the evaluator into a prepare step for the environment, with segment conditions compiled, and a per identity evaluation step. The prepared environment is kept per process for the environment last evaluated, and segments are evaluated without flags when only segments are asked for. Add a benchmark comparing identity evaluation across SDK versions. Generated with [Linear](https://linear.app/flagsmith/agent-session/51c26f09-5fe3-44a8-8e3d-be2cf9ac50ff) 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.
With local evaluation, flags that depend on other flags were ignored for identity flags. A segment conditioned on
$.flags.<feature>.enablednever matched, so the dependent feature kept its default. The legacy engine had no JSONPath support at all, so$.identity.*and$.environment.*conditions never matched either. Identity flags are now evaluated as flagsmith-engine 11.1.1 and the Edge API do.Changes
$.identity.*and$.environment.*JSONPath properties now work. The environment document'snameis now parsed.test/data/, so the existing 101-identity regression suite still runs. It passes unchanged against the new evaluator.get_identity_segmentsskips flag evaluation.bench/engine_bench.exsbenchmarks identity evaluation through the public API, so the same script runs against older versions.The new evaluator (
Flagsmith.Engine.Evaluator) works on an evaluation context.Flagsmith.Engine.Mappersbuilds that context from the environment document and the identity, soget_identity_feature_statesandget_identity_segmentskeep their signatures. The old public segment-matching helpers inFlagsmith.Engine(trait_match/3,traits_match_segment_rule/4, etc.) are left untouched but are no longer used by identity evaluation.The prepared environment is kept in the process dictionary, alongside the environment it was prepared from. It is reused only when the environment passed in matches it exactly (
^envmatch), so a changed environment is always prepared again; a test covers this. Each process holds at most one prepared environment. In the SDK, local identity evaluation runs in the poller process, so an environment is prepared once per refresh.To check the suite can fail: with flag resolution disabled, 13 of the 19 flag-dependency cases fail.
The minor release goes through release-please and needs a maintainer to merge the release PR.
Performance
Baseline is
mainat 77b5e9a, before flag dependency. Both sides ran the same script and fixture, interleaved, for 3 rounds of 5 s per workload. Setup: Elixir 1.15.2, OTP 26, 1 CPU.Times below are the median of the 3 per-round medians, per batch: 101 identities for v1, 100 for synthetic. Lower is better.
$.flags.<f>.enableddependency chainLimitations:
Flagsmith.Enginedirectly from a new short-lived process each time get the cold numbers.$.flags.*as a missing trait. Its time for that workload (65.2 ms) isn't comparable, so the table compares against this PR's own non-dependent run.Contributes to https://linear.app/flagsmith/issue/SDK-9/enable-flag-dependency-in-the-elixir-server-side-sdk
Review effort: 4/5