Skip to content

feat: Add client-side experiment exposure change listener tests - #602

Open
joker23 wants to merge 5 commits into
v3from
skz/sdk-3556/add-experiment-exposure-tests
Open

joker23 wants to merge 5 commits into
v3from
skz/sdk-3556/add-experiment-exposure-tests

Conversation

@joker23

@joker23 joker23 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a client-side suite for a flag that joins an experiment while its value and variation stay the same. Only reason.inExperiment, trackEvents, trackReason, version, and flagVersion change. Wrappers evaluate again only after a change notification, so an SDK that does not notify here loses the exposure events of control users.

Each case registers a general flag change listener, delivers the update, and expects a notification for the flag. It then evaluates the flag and checks that the feature event is a full event with the new reason and flag version. A control case on each path sends an identical update and expects no notification.

Delivery paths:

  • FDv2 stream partial payload
  • FDv2 stream full payload (xfer-full)
  • FDv2 polling synchronizer (long-running)
  • FDv1 fallback synchronizer (long-running, needs fdv1-fallback)

A separate group identifies a new context whose data has the same version and flagVersion but puts the context in the experiment. Comparing versions alone misses this change, so the SDK has to compare the whole result. Its control case identifies a new context with identical data.

The suite needs flag-change-listeners and a new opt-in capability, experiment-exposure-change. The draft FLAGCHG flag change listeners spec makes this behavior part of the general listener contract. Until that spec is accepted, SDKs opt in. After that, the suite gates on flag-change-listeners only and the capability goes away. docs/service_spec.md documents the new capability and now says flag-change-listeners applies to client-side SDKs too.

The feature event check moves out of client_side_events_experimentation.go into a shared helper, expectClientSideExperimentFeatureEvent, so the new suite and the existing experimentation test use the same check. The existing test checks the same things as before.

Additional context

  • FDv1 stream put and patch are not covered. The v3 mock stream only speaks FDv2, and the v2 harness has no listener protocol. feat: Run the test suite over FDv1 and FDv2 with the fdv1 and fdv2 capabilities (V2/V3 consolidation) #562 may make FDv1 stream coverage possible here later. It also touches testsuite_entry_point.go, service_params.go, and service_spec.md, so expect a small rebase.
  • The poll paths wait for the second poll at the SDK's minimum interval: 30s for browser SDKs and 5 minutes for other client SDKs. On mobile the two poll paths take about 20 to 40 minutes with -enable-long-running-tests.
  • The FDv1 case sets fdv1Fallback.pollIntervalMs. No earlier test does, so a test service that drops that field times out on that case.
  • The FDv1 case triggers fallback with a 200 polling initializer response that carries an FDv2 basis and X-LD-FD-Fallback: true. The existing directive tests use a 500 on the initializer or a 200 on the stream, so this combination is new.
  • The synchronizer's first payload repeats the old data. FLAGCHG says that payload must not notify when it is identical, so a compliant SDK is not affected. An SDK that notifies on every full payload can make the experiment case flaky, and the control case on that path fails every time for it.
  • Not run against a real SDK test service yet.

Related tickets

  • sdk-3556

Opened from termag


Note

Overview
Adds client-side harness coverage for experiment exposure: when a flag enters an experiment without changing value or variation, general flag change listeners must still fire so wrappers can re-evaluate and emit exposure events.

The new suite (doClientSideExperimentExposureTests) exercises FDv2 stream (partial and full), FDv2 polling, and FDv1 fallback delivery paths, with control cases that expect no notification on identical updates (except partial stream, where either behavior is allowed). Separate identify cases cover a new context that joins the experiment with unchanged versions versus identical data.

SDKs opt in via a temporary experiment-exposure-change capability (plus flag-change-listeners), documented in service_spec.md along with clarifying that flag-change-listeners applies to client-side SDKs. The client-side test entry point registers the new suite; experimentation event checks are centralized in expectClientSideExperimentFeatureEvent for reuse.

Reviewed by Cursor Bugbot for commit c0912e2. Bugbot is set up for automated code reviews on this repo. Configure here.

@joker23 joker23 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cursor review

@joker23
joker23 marked this pull request as ready for review November 20, 2026 20:07
@joker23
joker23 requested a review from a team as a code owner November 20, 2026 20:07

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cursor cursor 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.

Risk: medium. Not approved. Cursor Bugbot completed with no findings and Cursor Security Agent did not run; this PR is a non-trivial new listener and experiment-exposure test suite plus a new opt-in capability, which is above the low-risk approval threshold. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

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.

1 participant