Skip to content

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

Merged
emyller merged 2 commits into
mainfrom
feat/sdk-5-flag-dependency
Oct 30, 2026
Merged

emyller merged 2 commits into
mainfrom
feat/sdk-5-flag-dependency

Conversation

@emyller

@emyller emyller commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Local evaluation ignores conditions on other flags, so a flag that depends on another flag is served as if it didn't.

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

Changes

  • Conditions on other flags ($.flags.<feature>.enabled) are now evaluated; 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.
  • Flags without segment overrides report STATIC instead of DEFAULT.
  • Overrides without a priority no longer raise.

🤖 Generated with Claude Code

emyller and others added 2 commits October 30, 2026 16:36
Segment conditions can read another flag's evaluated result through
`$.flags.<feature>.enabled`, `.value` or `.variant`, as in flagsmith-engine.
Flags are resolved lazily and transitively; a flag in a dependency cycle is
served its default with reason `ERROR; code=CIRCULAR_DEPENDENCY`.

Also aligns with engine-test-data v3.12.1:
- Segments are evaluated without an identity.
- Every flag result carries a `variant`.
- Features without segment overrides report `STATIC`.
- Overrides without a priority rank last instead of raising `NameError`.

Local `get_environment_flags` now applies segments that need no identity
(`$.environment.*`, `$.flags.*`), as the Flagsmith API does, and skips
mapping identity overrides.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@emyller
emyller requested a review from a team as a code owner October 30, 2026 19:38
@emyller
emyller requested review from khvn26 and removed request for a team October 30, 2026 19:38
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

SDK-5

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
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: 6add9854-9e56-44ed-ab1a-464a4d9440af
Commits

Reviewing files that changed from the base of the PR and between a95445c and ca46600.

Files selected for processing: 12
  • .github/workflows/sdk-spec.yml
  • .gitmodules
  • lib/flagsmith.rb
  • lib/flagsmith/engine/core.rb
  • lib/flagsmith/engine/features/constants.rb
  • lib/flagsmith/engine/lazy_flags.rb
  • lib/flagsmith/engine/mappers.rb
  • lib/flagsmith/engine/segments/constants.rb
  • lib/flagsmith/engine/segments/evaluator.rb
  • sdk-spec/steps.rb
  • spec/engine-test-data
  • spec/engine/unit/evaluation_context_mappers_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The client now builds an environment evaluation context that excludes segments with identity-dependent rules. The engine adds lazy flag resolution with cycle handling, updates segment override selection, and includes targeting reasons and variant fields in flag results. The segment evaluator caches JSONPath queries. The SDK spec workflow and test data are updated for the local-evaluation spec.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: Minimal · up to ca466

This change adds flag-dependency evaluation and identity-free segment handling for local evaluation. No concrete merge-blocking risk was found in review, and the remote environment-flags behavior is unchanged.

- [ ] 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

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Oct 30, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 55.53%

1 warning

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 2 improved benchmarks
✅ 13 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ getEnvironmentFlags[large] 71.1 ms 39.1 ms +82.1%
⚡ getEnvironmentFlags[medium] 11.6 ms 8.7 ms +32.84%

Tip

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


Comparing feat/sdk-5-flag-dependency (ca46600) with main (a95445c)

Open in CodSpeed

@khvn26 khvn26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@emyller
emyller merged commit e4efc8f into main Oct 30, 2026
11 checks passed
@emyller
emyller deleted the feat/sdk-5-flag-dependency branch October 30, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants