Skip to content

feat(experimentation): default to control when rollout segment is created#7905

Merged
gagantrivedi merged 11 commits into
mainfrom
feat/experiment-rollout-default-control-allocation
Jul 16, 2026
Merged

feat(experimentation): default to control when rollout segment is created#7905
gagantrivedi merged 11 commits into
mainfrom
feat/experiment-rollout-default-control-allocation

Conversation

@gagantrivedi

@gagantrivedi gagantrivedi commented Jun 29, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

When a feature is first added to an experiment's rollout — the moment the rollout system segment is created — zero every variant's allocation on the environment-default feature state, so identities outside the rollout cohort receive control (the unallocated remainder) while the experiment runs.

  • The rollout segment override is unchanged: it keeps the experiment's own split.
  • Only runs when the rollout segment is first created; later rollout updates leave the default allocations alone, so manual edits to the default survive.
  • Goes through the version-aware update_flag path, working under both v1 and v2 versioning.

How did you test this code?

Unit tests (make test): service tests covering first-rollout zeroing and later updates leaving the default alone; view tests asserting create-with-rollout zeroes the default and preserves the override split under both v1 and v2 versioning. mypy, ruff, and flagsmith-lint-tests clean.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jul 16, 2026 6:41am
flagsmith-frontend-preview Ignored Ignored Preview Jul 16, 2026 6:41am
flagsmith-frontend-staging Ignored Ignored Preview Jul 16, 2026 6:41am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API feature New feature or request labels Jun 29, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (62a8143) to head (93069f0).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7905    +/-   ##
========================================
  Coverage   98.63%   98.64%            
========================================
  Files        1497     1501     +4     
  Lines       59261    59466   +205     
========================================
+ Hits        58455    58660   +205     
  Misses        806      806            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 30, 2026
@gagantrivedi
gagantrivedi force-pushed the feat/experiment-rollout-default-control-allocation branch from 8451662 to 8275f6d Compare June 30, 2026 05:20
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 30, 2026
…ated

When a feature is first added to an experiment's rollout, zero every
variant's allocation on the feature's environment-default feature state
so control (the unallocated remainder) receives 100% of out-of-rollout
traffic. The rollout segment override keeps the experiment's own split.

This only runs when the rollout segment is first created; tuning the
rollout of a running experiment leaves the default allocations alone.
@gagantrivedi
gagantrivedi force-pushed the feat/experiment-rollout-default-control-allocation branch from 8275f6d to cf19595 Compare July 14, 2026 11:14
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 732561bf-7acb-41ae-866c-162e3757e0ca

📥 Commits

Reviewing files that changed from the base of the PR and between bf5b044 and 93069f0.

📒 Files selected for processing (1)
  • api/experimentation/services.py

📝 Walkthrough

Walkthrough

Experiment rollout application now zeroes environment-default multivariate allocations when creating the first rollout segment, while preserving the rollout segment’s submitted allocation split. Existing rollout updates leave manually edited default allocations unchanged. Feature-state value serialisation is centralised and typed, including boolean formatting. Unit and view tests cover standard and versioned environment paths, and warehouse event documentation references are updated.

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


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

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 15, 2026
@github-actions github-actions Bot added the docs Documentation updates label Jul 15, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 15, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 15, 2026
@github-actions github-actions Bot added the docs Documentation updates label Jul 15, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 15, 2026
@gagantrivedi

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 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.

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

Looks good overall but we should fix the null => "None" before moving forward

Comment thread api/experimentation/services.py
Comment thread api/experimentation/services.py Outdated
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 16, 2026

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/experimentation/services.py (1)

683-687: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Re-check the experiment status after acquiring the lock.

The COMPLETED guard runs before refresh_from_db(). If another transaction completes the experiment between these operations, this transaction can still write a rollout for a completed experiment. Repeat the guard immediately after refreshing the locked row.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6d63392d-3b95-4df3-bacb-9b95934e624b

📥 Commits

Reviewing files that changed from the base of the PR and between 166b3a1 and 6417f9d.

📒 Files selected for processing (3)
  • api/experimentation/services.py
  • api/tests/unit/experimentation/test_services.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

@github-actions github-actions Bot added the docs Documentation updates label Jul 16, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 16, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 16, 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.

👍

@gagantrivedi
gagantrivedi merged commit d53e0d7 into main Jul 16, 2026
34 checks passed
@gagantrivedi
gagantrivedi deleted the feat/experiment-rollout-default-control-allocation branch July 16, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants