build condition stack once per experiment#3238
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes within-subject experiment assignment by precomputing the (potentially expensive) ordered condition/factor queue once per experiment+user and reusing it across all decision points, rather than rebuilding the queue per decision point.
Changes:
- Adds a helper to precompute within-subject ordered conditions/factors once per experiment+user.
- Adds a helper to apply decision-point-specific payloads from a prebuilt lookup map to the precomputed ordering.
- Updates experiment assignment mapping to reuse the precomputed ordering and payload lookup across decision points.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/backend/src/api/services/ExperimentAssignmentService.ts | Precomputes within-subject condition ordering + payload lookup once, then reuses for each decision point. |
| packages/backend/src/api/Algorithms.ts | Introduces new helper functions to precompute within-subject ordering and then apply decision-point payloads efficiently. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Applies decision-point-specific payloads to a pre-computed within-subjects condition order | ||
| * and returns the final assignment for one decision point. Pair with | ||
| * buildWithinSubjectOrderedConditions + a conditionPayloadMap built once per experiment. | ||
| */ |
There was a problem hiding this comment.
i think this is right, i don't know if there's going to be a need for it?
danoswaltCL
left a comment
There was a problem hiding this comment.
this looks good to me, just piggybacking on the copilot comment that we don't really need to keep the old implementation method around if it's unused now?
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
No description provided.