Repository navigation
feat(Flag Dependency): Evaluate flags that depend on other flags in local evaluation - #238
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 Segment conditions on `$.flags.<feature>.enabled`, `.value` or `.variant` now resolve the referenced flag, following transitive dependencies. Flags caught in a dependency cycle serve their environment default with reason `ERROR; code=CIRCULAR_DEPENDENCY`, and segments reading them do not match. Ports Flagsmith/flagsmith-engine#343. Bumps engine-test-data to v3.11.0, which adds the flag dependency cases. Generated with [Linear](https://linear.app/flagsmith/agent-session/23ffa3ca-707e-4c94-9b8e-d730e6e58c4c) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
…aseline cost The dependency resolver now allocates its state only once a condition reads `$.flags`, segment keys are sorted once per evaluation, flag fields are read directly instead of through a JSONPath query, and flags resolved as dependencies are not evaluated twice. Generated with [Linear](https://linear.app/flagsmith/agent-session/23ffa3ca-707e-4c94-9b8e-d730e6e58c4c) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
emyller
force-pushed
the
linear/sdk-3-enable-flag-dependency-in-the-go-server-side-sdk-3091
branch
from
October 27, 2026 02:23
5649d9a to
0cd5780
Compare
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.
Local evaluation in the Go SDK ignored Flag Dependency. A segment condition on another flag (
$.flags.<feature>.enabled,.valueor.variant) never resolved, so a feature that should switch on when its prerequisite is enabled kept its default. This change ports flagsmith-engine#343, so local evaluation now matches the engine and Edge API.Changes
ERROR; code=CIRCULAR_DEPENDENCYand serve the environment default. Segments that read such a flag don't match.$.count as flag paths.$['flags']…is still read as a trait name, as in the engine.The shared data lists matched segments in the order the context declares them. Go segment maps have no declaration order, and the engine always sorts segments by key, so the test harness now compares matched segments regardless of order.
I didn't go up to v3.12.x (#227) here. v3.12.0 also expects the new
STATICreason (flagsmith-engine#347), which would change reasons users already see on environment flags. That deserves its own PR.When merged, release-please will propose a minor release (5.4.0). A maintainer ships it.
Performance
BenchmarkGetEvaluationResultcalls only the publicflagengine.GetEvaluationResult, so the same file runs on the baseline,626676c(mainbefore this PR). Workloads:$.flagsBoth sides read the same v3.11.0 test data. Runs were interleaved, 10 per side, on Go 1.25.0, linux/amd64, a single-vCPU Xeon 8375C.
The first version of this PR was 19–28% slower even without flag dependencies. That's fixed in 5649d9a: the resolver now sets up its state only when a condition reads
$.flags, segment keys are sorted once per evaluation, flag fields are read directly instead of through a JSONPath query, and dependency flags are not evaluated twice. The extra allocations are the resolver itself (one per evaluation) plus its per-evaluation index once dependencies are read.Limitations:
GetIdentityFlagswrap the same function, but I didn't benchmark them separately.Contributes to https://linear.app/flagsmith/issue/SDK-3/enable-flag-dependency-in-the-go-server-side-sdk
Review effort: 3/5