Skip to content

Merge/6 5 5 precompute and large lists#3227

Open
danoswaltCL wants to merge 21 commits into
devfrom
merge/6-5-5-precompute-and-large-lists
Open

Merge/6 5 5 precompute and large lists#3227
danoswaltCL wants to merge 21 commits into
devfrom
merge/6-5-5-precompute-and-large-lists

Conversation

@danoswaltCL

Copy link
Copy Markdown
Collaborator

just merging down the changes from 6.5

danoswaltCL and others added 21 commits June 25, 2026 13:55
* use the aggregated count for all repeated enrollments to determine round-robin cycle

* get results for each experiment, rather than all

* explicit type

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix query

* add unit test for single rotation counter across DPs

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Feature flags whose inclusion/exclusion lists have tens of thousands of members made the
details page, list edits, and enable/disable toggles slow or broken. This reworks those
paths to avoid loading and rewriting full member lists unnecessarily.

Detail page load:
- Add FeatureFlagService.findOneForDetails (counts-only via loadRelationCountAndMap, no
  member arrays, no Cartesian join) and use it for GET /flags/:id. findOne keeps loading
  full members for callers that need them (exports). updateList also uses the counts-only
  fetch since it only needs the flag id/name.
- Frontend renders individualForSegmentCount / groupForSegmentCount; drops the
  members-dependent values tooltip.

Editing a list:
- Add GET /segments/:id/members (getSegmentByIdWithMembers) that returns a segment,
  including private lists, with its members; the edit modal lazy-loads through it.
  getSegmentById still excludes private segments.
- Clear existing members on update with a single DELETE ... WHERE segmentId = :id per
  member table instead of a 20k-element per-row delete criteria (and drop the pre-SELECT).

Enable/disable toggle:
- Add PATCH /flags/{inclusion,exclusion}List/:id/status (updateListStatus) that flips only
  the enabled column without rewriting members; wire the inclusions toggle to it.

Add/Edit modal button:
- Set the upsert-loading flag on list update actions (not just add/delete), expose the
  correct feature-flag selector, and combine loading across the flag/experiment/segment
  stores so the primary button disables during any in-flight add or edit and can't be
  double-submitted.

Tests: unit coverage for findOneForDetails, updateListStatus, getSegmentByIdWithMembers,
delete-by-segmentId, and the new controller routes; the FeatureFlag inclusion/exclusion
integration case now also exercises the counts-only view, private members fetch, and
status toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Group IDs in feature_flag_precomputed_segment were stored bare in the same
flat arrays as individual user IDs, so a group ID could collide with a user
ID and flip an include/exclude decision. Matching also ignored group type,
diverging from the type-aware experiment / on-the-fly resolution path.

Namespace group IDs as `type:groupId` (individuals stay bare) via a shared
precomputedGroupKey helper used by both the write and read paths. Add a
migration that clears the table so the startup backfill rebuilds every row in
the new format; missing rows fall back to on-the-fly resolution in the interim.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…t-ui-support

lighten flag detail load and list add/edit for large lists
Brings in the large-list UI support work (perf: lighten flag detail load and
list add/edit; block accidental save while members load) plus the round-robin
cycle hotfix, and wires the new UI-support write paths through the precomputed-
segment recompute so the flat feature_flag_precomputed_segment arrays stay
consistent with the new flows.

Conflict resolutions (packages/backend):
- FeatureFlagService.updateList: kept the branch's withRecompute wrapper (doUpdate
  runs in its own transaction; recompute fires fire-and-forget after commit) and
  adopted release's counts-only findOneForDetails fetch.
- FeatureFlagService.updateListStatus (NEW from release — the enable/disable list
  toggle the large-list UI uses): now routed through withRecompute. recomputeForFlag
  only flattens *enabled* lists, so a status flip changes the precomputed member set;
  the resolver yields the affected flag id only when the enabled value actually changed.
- SegmentService.addSegmentDataWithPipeline: took release's perf win (drop the
  pre-SELECT of full member arrays) but kept the branch's tested repository delete
  methods (deleteIndividualForSegmentById / deleteGroupForSegmentById), honoring the
  "repositories own all query-building" convention; call them unconditionally.

Test updates:
- updateFeatureFlagInDB now reads the old flag via findOneForDetails (release's perf
  change); updated the two context-change recompute tests to mock findOneForDetails.
- Added updateListStatus tests asserting recompute fires on a real status flip and is
  skipped when the status is unchanged.
- SegmentService delete-by-segmentId test asserts the repository delete methods.

Verified: backend + frontend typecheck, 905 backend unit tests pass (integration
suite skipped — requires a live DB).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ments-for-flags

Wip/precomputed segments for flags
@danoswaltCL danoswaltCL requested review from bcb37 and zackcl July 9, 2026 18:17
@bcb37

bcb37 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Many of these commits are already in dev.

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.

3 participants