Wip/share pooling add context to mark#3180
Draft
bcb37 wants to merge 8 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the backend “mark” path to make experiment resolution consistent with the “assign” path by introducing an explicit context parameter, switching mark-time experiment selection to use context-scoped cached experiments, and adding integration coverage for state filtering and cross-context isolation.
Changes:
- Add
contextto mark request validation and thread it through controllers →ExperimentAssignmentService.markExperimentPoint. - Replace mark-specific decision-point caching with
getCachedValidExperiments(context)and consolidate selection logic inresolveExperimentForMarkPoint. - Expand integration tests to validate cancelled-experiment exclusion and prevent cross-context experiment pool contamination; update JS/Java clients to send
contextin mark requests.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backend/test/integration/utils/index.ts | Updates test helper to pass context into markExperimentPoint. |
| packages/backend/test/integration/UserNotDefined/index.ts | Adjusts mark call signature in the “user not defined” integration case. |
| packages/backend/test/integration/index.test.ts | Registers new integration test cases for mark behavior. |
| packages/backend/test/integration/Experiment/withinSubject/MetricQueriesCheck.ts | Threads context through within-subject metric query mark calls. |
| packages/backend/test/integration/Experiment/stratification/MetricQueriesCheck.ts | Threads context through stratification metric query mark calls. |
| packages/backend/test/integration/Experiment/markExperimentPoint/NoExperiment.ts | Passes explicit context when marking in the NoExperiment case. |
| packages/backend/test/integration/Experiment/markExperimentPoint/index.ts | Exposes new markExperimentPoint integration test cases. |
| packages/backend/test/integration/Experiment/markExperimentPoint/ContextContamination.ts | Adds integration test ensuring no cross-context contamination for shared site/target. |
| packages/backend/test/integration/Experiment/markExperimentPoint/CancelledExperimentStateFilter.ts | Adds integration test ensuring cancelled experiments are excluded from mark resolution. |
| packages/backend/test/integration/Experiment/experimentContext/ExperimentContextAssignments.ts | Updates experiment-context integration flow to pass mark context. |
| packages/backend/src/api/services/ExperimentService.ts | Simplifies cache invalidation to remove mark-cache key deletion. |
| packages/backend/src/api/services/ExperimentAssignmentService.ts | Adds context-aware experiment resolution for mark and consolidates selection logic. |
| packages/backend/src/api/controllers/validators/MarkExperimentValidator.v6.ts | Makes context required for v6 mark requests. |
| packages/backend/src/api/controllers/validators/MarkExperimentValidator.v5.ts | Adds optional context for v5 mark requests (backward compatibility). |
| packages/backend/src/api/controllers/ExperimentClientController.v6.ts | Passes validated context through to mark service call. |
| packages/backend/src/api/controllers/ExperimentClientController.v5.ts | Passes optional context (currently defaulting to empty string) to mark service call. |
| docs/mark-context-refactor-plan.md | Documents the rationale and phased plan for the mark-path refactor. |
| clientlibs/js/src/UpGradeClient/generateUUID.spec.ts | Minor test cleanup (trailing whitespace removal). |
| clientlibs/js/src/types/requests.ts | Adds context to the JS mark request body type. |
| clientlibs/js/src/ApiService/ApiService.ts | Includes configured context in JS mark request bodies. |
| clientlibs/js/src/ApiService/ApiService.spec.ts | Adds JS client tests verifying context is included in mark requests. |
| clientlibs/java/src/main/java/org/upgradeplatform/requestbeans/MarkExperimentRequest.java | Adds context to the Java mark request bean and constructors. |
| clientlibs/java/src/main/java/org/upgradeplatform/client/ExperimentClient.java | Threads client context into Java mark request construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+159
to
+165
| return { | ||
| experiments: [], | ||
| experimentId, | ||
| isUserExcluded: false, | ||
| isGroupExcluded: false, | ||
| exclusionReason: [], | ||
| }; |
Comment on lines
481
to
485
| experiment.status, | ||
| experiment.data.assignedCondition?.conditionCode ?? null, | ||
| request.logger, | ||
| experiment.context ?? '', | ||
| experiment.data.assignedCondition?.experimentId ?? null, |
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.
No description provided.