feat: support Mutex and Holdout groups for web experiment#324
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Local flags with remote dependencies applied prematurely
- Added filter to exclude remoteFlagKeys members from localFlagKeys at line 218, ensuring flags with transitive remote dependencies wait for fetchRemoteFlags() before being applied.
Or push these changes by commenting:
@cursor push 59cf49554e
Preview (59cf49554e)
diff --git a/packages/experiment-tag/src/experiment.ts b/packages/experiment-tag/src/experiment.ts
--- a/packages/experiment-tag/src/experiment.ts
+++ b/packages/experiment-tag/src/experiment.ts
@@ -214,9 +214,12 @@
...this.config,
});
// Get all the locally available flag keys from the SDK.
+ // Exclude flags that were moved to remoteFlagKeys due to transitive dependencies.
const variants = this.experimentClient.all();
this.localFlagKeys = Object.keys(variants).filter(
- (key) => variants[key]?.metadata?.evaluationMode === 'local',
+ (key) =>
+ variants[key]?.metadata?.evaluationMode === 'local' &&
+ !this.remoteFlagKeys.includes(key),
);
this.messageBus = new MessageBus();
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 7b7dba7. Configure here.
ansonchen2
approved these changes
May 22, 2026
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.


Summary
Support Mutex and Holdout groups for web experiment.
Flags that transitively depend on a remote-evaluated flag (e.g. a Mutex or Holdout parent) are now promoted to remote evaluation via a fixed-point dependency walk. This ensures child flags wait for their remote dependencies to be fetched before bucketing runs, preventing incorrect variant assignment.
Checklist
Note
Medium Risk
Changes flag evaluation ordering and startup timing for experiments with flag dependencies or holdout/mutex flags, which can affect which variants users see on first paint.
Overview
Web experiment startup now treats local flags that depend on a remote flag (including transitive chains) as remote so variant application waits until remote parents are fetched, avoiding wrong mutex/holdout bucketing from stale parent state. Only flags promoted via that dependency walk are removed from the early local apply pass; directly remote flags that are session-cached as local still get the fast-path local apply.
When any initial flag key starts with
holdout-ormutex-,start()awaitsintegrationManager.ready()before applying variants so bucketing hasuser_id/device_idfrom the Amplitude integration setup.Adds a test that a depth-2 local→local→remote dependency chain is not applied on the first local
applyVariantscall and is applied after remote fetch.Reviewed by Cursor Bugbot for commit d232bbf. Bugbot is set up for automated code reviews on this repo. Configure here.