Skip to content

feat: Evaluate flags that depend on other flags - #150

Merged
emyller merged 11 commits into
mainfrom
linear/sdk-6-enable-flag-dependency-in-the-php-server-side-sdk-3e8e
Nov 4, 2026
Merged

emyller merged 11 commits into
mainfrom
linear/sdk-6-enable-flag-dependency-in-the-php-server-side-sdk-3e8e

Conversation

@linear-code

@linear-code linear-code Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Local evaluation ignores segments that depend on other flags ($.flags.<feature>.enabled), unlike flagsmith-engine and the Flagsmith API.

Closes SDK-6. Tested by engine-test-data v3.12.1 and sdk-spec v0.7.0.

Changes

  • Conditions on other flags ($.flags.<feature>.enabled, .value and .variant) are now evaluated, including chains of dependencies; circular dependencies serve the default with reason ERROR; code=CIRCULAR_DEPENDENCY.
  • Environment flags apply segments that don't need an identity, instead of ignoring all segments.
  • Flag results report the variant they were evaluated to.
  • Flags without segment overrides report STATIC instead of DEFAULT.
  • CI runs engine-test-data v3.12.1 and sdk-spec v0.7.0.

🤖 Generated with Claude Code

Closes #140

Segment conditions can now read other flags via `$.flags.<name>`,
resolved lazily with a cycle guard, mirroring flagsmith-engine. Flag
results also carry a `variant` key. Bumps engine-test-data to v3.11.0.

Generated with [Linear](https://linear.app/flagsmith/agent-session/d9c8ddc7-fa40-4842-80da-7e01be1b4f77)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@linear-code
linear-code Bot requested a review from a team as a code owner October 21, 2026 17:14
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c1e2041e-11f1-41c4-9763-6ffc8ecf5063

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Skip the lazy flags when there are no segments, and break the
context/flags reference cycle so each evaluation is freed by reference
counting rather than left to the cycle collector.

Generated with [Linear](https://linear.app/flagsmith/agent-session/d9c8ddc7-fa40-4842-80da-7e01be1b4f77)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@emyller
emyller force-pushed the linear/sdk-6-enable-flag-dependency-in-the-php-server-side-sdk-3e8e branch from 1649a50 to 744057b Compare October 27, 2026 02:23
emyller and others added 4 commits November 2, 2026 17:22
Bumps engine-test-data to v3.12.1, which expects it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Environment flags can now follow the flags they depend on, as in the Flagsmith API.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codspeed

codspeed Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 37.47%

⚡ 15 improved benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ getEnvironmentFlags[large] 16.4 s 6.9 s ×2.4
⚡ getEnvironmentFlags[small] 566.6 ms 321.2 ms +76.43%
⚡ getIdentityFlagsNoTraits[small] 1,091.9 ms 687.4 ms +58.84%
⚡ getIdentityFlagsWithIdentityOverrides[small] 1,089.6 ms 686.2 ms +58.8%
⚡ getEnvironmentFlags[medium] 2.7 s 1.8 s +50.16%
⚡ getIdentitySegmentsWithTraits[small] 1,301.4 ms 929.1 ms +40.07%
⚡ getIdentityFlagsWithTraits[small] 1,326.4 ms 952.7 ms +39.23%
⚡ getIdentityFlagsNoTraits[large] 27 s 21.6 s +25.39%
⚡ getIdentityFlagsWithIdentityOverrides[large] 26.3 s 21.4 s +23.05%
⚡ getIdentityFlagsWithTraits[large] 29.3 s 24.8 s +18.24%
⚡ getIdentitySegmentsWithTraits[large] 27.4 s 23.4 s +17.19%
⚡ getIdentityFlagsNoTraits[medium] 4.3 s 3.6 s +17.17%
⚡ getIdentityFlagsWithIdentityOverrides[medium] 4.3 s 3.6 s +16.72%
⚡ getIdentitySegmentsWithTraits[medium] 4.1 s 3.6 s +15.1%
⚡ getIdentityFlagsWithTraits[medium] 4.4 s 3.9 s +13.55%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing linear/sdk-6-enable-flag-dependency-in-the-php-server-side-sdk-3e8e (65bd629) with main (a0d835d)

Open in CodSpeed

emyller and others added 3 commits November 2, 2026 18:11
Conditions such as `$.identity.identifier` or `$.flags.<feature>.enabled` skip JSONPath evaluation. Other paths are still evaluated by softcreatr/jsonpath.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Environment flags no longer deep-clone the context and select its identity-free segments on every call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The engine leaves the context it evaluates untouched. Identity override rules now map an empty list of sub-rules, which deep-cloning used to fill in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@emyller emyller self-assigned this Nov 3, 2026
Zaimwa9
Zaimwa9 previously requested changes Nov 4, 2026

@Zaimwa9 Zaimwa9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One parser question to settle regarding jsonpath and just as in elixir, include the key in the mapper.

A request change one click away from an approval

Comment thread src/Engine/Engine.php Resolved
emyller and others added 2 commits November 4, 2026 17:47
Flagsmith writes the feature name of a flag dependency as JSON, which escapes non-ASCII characters. The JSONPath library looked those escapes up verbatim, so such a dependency never matched.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A condition value not coercible to the trait value type, e.g. `95 > "90.5"`, no longer matches.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@emyller
emyller dismissed Zaimwa9’s stale review November 4, 2026 21:12

Concerns addressed while on opposite timezone. Thanks!

@emyller
emyller merged commit 190156a into main Nov 4, 2026
9 checks passed
@emyller
emyller deleted the linear/sdk-6-enable-flag-dependency-in-the-php-server-side-sdk-3e8e branch November 4, 2026 21:13
emyller pushed a commit that referenced this pull request Nov 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[5.2.0](v5.1.2...v5.2.0)
(2026-11-04)


### Features

* **CI:** Set up CodSpeed
([#151](#151))
([a0d835d](a0d835d))
* Evaluate flags that depend on other flags
([#150](#150))
([190156a](190156a))


### Bug Fixes

* Mapping identity overrides with multiple features fails
([#143](#143))
([fd4bcc9](fd4bcc9))


### CI

* Label Renovate's SDK spec bump PRs
([#148](#148))
([351aeae](351aeae))
* Run the Flagsmith SDK behavioural spec
([#147](#147))
([634470d](634470d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support $.flags context values in segment conditions

3 participants