Skip to content

feat(Flag Dependency): Evaluate flags that depend on other flags - #74

Merged
emyller merged 6 commits into
mainfrom
feat/sdk-8-flag-dependency
Nov 2, 2026
Merged

emyller merged 6 commits into
mainfrom
feat/sdk-8-flag-dependency

Conversation

@emyller

@emyller emyller commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Local evaluation ignores segments that target flags by other flags, and environment flags ignore every segment, so the SDK serves different flags than Flagsmith.

Closes SDK-8. Depends on Flagsmith/flagsmith-rust-flag-engine#44; merge once it's released. Tested by sdk-spec v0.7.0.

Changes

  • Identity and environment flags apply overrides of segments that depend on other flags.
  • Environment flags apply overrides of segments that need no identity.

🤖 Generated with Claude Code

Closes #60

Local evaluation now serves flags that depend on other flags, and environment
flags apply segments that need no identity, as Flagsmith does.

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 20:22
@emyller
emyller requested review from khvn26 and removed request for a team October 30, 2026 20:22
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

SDK-8

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The flag engine dependency updates to version 0.7.0. Local evaluation stores and uses an identity-free evaluation context, and the integration test now expects a matching segment override. The SDK spec adds a constructor for a client with local evaluation enabled. Its workflow updates the spec reference and adds the core or local-evaluation tags.

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

Merge Risk: Minimal · up to fb3be

The change enables segment overrides for environment flags. Adding a nonmatching-segment test would strengthen coverage; workflow pinning remains a pre-existing follow-up. Neither finding establishes a merge blocker.

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

@emyller emyller self-assigned this Oct 30, 2026
@codspeed

codspeed Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.3

⚡ 14 improved benchmarks
✅ 1 untouched benchmark
⏩ 15 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ get_identity_flags_no_traits[small] 1,400.3 µs 388.8 µs ×3.6
⚡ get_identity_flags_with_identity_overrides[small] 1,407.1 µs 393.6 µs ×3.6
⚡ get_identity_flags_no_traits[large] 45.1 ms 15.4 ms ×2.9
⚡ get_identity_flags_with_identity_overrides[large] 45.1 ms 15.4 ms ×2.9
⚡ get_identity_segments_with_traits[large] 52 ms 20.8 ms ×2.5
⚡ get_identity_flags_no_traits[medium] 7.5 ms 3 ms ×2.5
⚡ get_identity_flags_with_identity_overrides[medium] 7.5 ms 3 ms ×2.5
⚡ get_identity_flags_with_traits[large] 54 ms 22.7 ms ×2.4
⚡ get_identity_segments_with_traits[medium] 8.6 ms 3.9 ms ×2.2
⚡ get_identity_flags_with_traits[medium] 9.1 ms 4.5 ms ×2
⚡ get_identity_segments_with_traits[small] 2.2 ms 1.2 ms +89.58%
⚡ get_identity_flags_with_traits[small] 2.2 ms 1.2 ms +87.2%
⚡ get_environment_flags[medium] 2.1 ms 1.6 ms +33.68%
⚡ get_environment_flags[large] 7.9 ms 6.1 ms +30.38%

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-8-flag-dependency (fb3be60) with main (6649750)

Open in CodSpeed

Footnotes

  1. 15 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

emyller and others added 4 commits October 30, 2026 18:56
… environment update

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Flagsmith/flagsmith-rust-flag-engine#44 @ c261f544

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up Comments

Minor follow-up Pin the reusable workflow to a commit SHA.

14-14: Minor · Security & Privacy · Quick win

Pin the reusable workflow to a commit SHA.

uses: references the tag v0.7.0, which the upstream repository can move. A later run could then execute different workflow code. The job holds only contents: read and passes no secrets, which limits the impact. Pin uses: and spec-ref to the commit SHA that v0.7.0 resolves to, and keep both values in sync.

Open the source location

Nitpick Add a negative-case test for the segment condition on the environment name.

124-124: Trivial · Maintainability & Code Quality · Quick win

Add a negative-case test for the segment condition on the environment name.

The only segment-override test uses an environment named "Test Environment", which matches the segment condition. An implementation that applies the override without evaluating the condition still passes this test. A test with a non-matching environment name detects that regression. It asserts that the base feature value is returned.

Suggested test
+#[rstest]
+fn test_get_environment_flags__local_evaluation_with_segment_not_matching_environment__returns_base_value(
+    mock_server: MockServer,
+    environment_json_with_context_value_override: serde_json::Value,
+) {
+    // Given
+    let mut environment_json = environment_json_with_context_value_override;
+    environment_json["name"] = serde_json::json!("Other Environment");
+    let api_mock = mock_server.mock(|when, then| {
+        when.method(GET)
+            .path("/api/v1/environment-document/")
+            .header("X-Environment-Key", ENVIRONMENT_KEY);
+        then.status(200).json_body(environment_json);
+    });
+    let url = mock_server.url("/api/v1/");
+    let flagsmith_options = FlagsmithOptions {
+        api_url: url,
+        enable_local_evaluation: true,
+        ..Default::default()
+    };
+    let flagsmith = Flagsmith::new(ENVIRONMENT_KEY.to_string(), flagsmith_options);
+
+    // When
+    let flags = flagsmith.get_environment_flags().unwrap();
+    let flag_value = flags
+        .get_feature_value_as_string(fixtures::FEATURE_1_NAME)
+        .unwrap();
+
+    // Then
+    assert_eq!(flag_value, fixtures::FEATURE_1_STR_VALUE);
+    api_mock.assert();
+}

Open the source location


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: d4caa908-2a2e-4baf-a988-5b816185a1ed
Commits

Reviewing files that changed from the base of the PR and between 6649750 and fb3be60.

Files ignored due to path filters: 2
  • Cargo.lock is excluded by !**/*.lock
  • benchmarks/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 8
  • .github/workflows/sdk-spec.yml
  • Cargo.toml
  • benchmarks/Cargo.toml
  • sdk-spec/Cargo.toml
  • sdk-spec/steps.rs
  • src/flagsmith/mod.rs
  • tests/fixtures/mod.rs
  • tests/integration_test.rs

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

@emyller
emyller merged commit a1a22e6 into main Nov 2, 2026
7 checks passed
@emyller
emyller deleted the feat/sdk-8-flag-dependency branch November 2, 2026 19:14
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.

Support $.flags context values in segment conditions

2 participants