Fix/mooclet priors rebased#3093
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Mooclet TS-configurable experiments to support per-condition priors, display prior/posterior counts and an estimated Thompson-sampling “weight” in the UI, and wires up a new modal for editing priors.
Changes:
- Update shared
upgrade_typesto modelpriorandcurrent_posteriorsasRecord<string, …>and extend rewards-summary rows with prior/posterior/estimated-weight fields. - Add a frontend “Edit condition prior” modal and integrate it into the experiment conditions section (plus i18n strings).
- Add backend logic to fetch TS policy parameters and compute an estimated Thompson weight per condition for the rewards summary response.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/index.ts | Re-export Prior / CurrentPosteriors for downstream usage. |
| packages/types/src/Mooclet/index.ts | Extend rewards-summary row type; remove total and add prior/posterior/estimated-weight fields. |
| packages/types/src/Mooclet/MoocletTSConfigurablePolicyParametersDTO.ts | Change prior to per-key record and add current_posteriors record. |
| packages/frontend/projects/upgrade/src/assets/i18n/en.json | Add labels/tooltips for priors, posteriors, and estimated weight + prior modal strings. |
| packages/frontend/projects/upgrade/src/app/shared/services/common-dialog.service.ts | Add dialog open helper for the new “edit condition prior” modal. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../ts-configurable-reward-count-table.component.ts | Add columns + tooltip generation for estimated weight. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../ts-configurable-reward-count-table.component.html | Render prior/posterior columns and estimated-weight column with tooltip. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../ts-configurable-reward-count-table.component.scss | Adjust table column sizing/formatting for the new columns. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../enrollment-condition-expandable-row.component.scss | Add hidden-column styling for mooclet-specific table behavior. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../enrollment-condition-expandable-row.component.html | Hide weight header/cell content for mooclet experiments. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../experiment-conditions-table.component.ts | Add prior input + editPrior output; switch displayed columns for mooclet experiments. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../experiment-conditions-table.component.html | Add prior success/failure columns and edit button for priors. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../experiment-conditions-table.component.scss | Add prior/prior-edit column sizing/alignment. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../experiment-conditions-section-card.component.ts | Wire conditions-section prior editing into dialog + experiment update. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/.../experiment-conditions-section-card.component.html | Pass prior into table and bind prior-edit event. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/modals/upsert-experiment-modal/.../ts-configurable-policy-parameters-form.component.ts | Remove prior fields from the TS-configurable upsert form. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/modals/upsert-experiment-modal/.../ts-configurable-policy-parameters-form.component.html | Remove prior inputs from the TS-configurable upsert form UI. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/modals/edit-condition-prior-modal/edit-condition-prior-modal.component.ts | New modal component for editing per-condition priors. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/modals/edit-condition-prior-modal/edit-condition-prior-modal.component.html | Modal UI for editing successes/failures priors per condition. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/experiments/modals/edit-condition-prior-modal/edit-condition-prior-modal.component.scss | Styling for the prior-edit modal table/inputs. |
| packages/frontend/projects/upgrade/src/app/core/experiments/store/experiments.model.ts | Remove TS-configurable overview labels for global prior fields. |
| packages/frontend/projects/upgrade/src/app/core/experiments/mooclet-helper.service.ts | Remove flat prior fields and add validators for the new prior editor. |
| packages/frontend/projects/upgrade/src/app/core/experiments/mooclet-helper.service.spec.ts | Update tests to reflect removal of global prior fields. |
| packages/frontend/projects/upgrade/src/app/core/experiments/experiments.service.ts | Add store update helper to persist per-condition prior changes. |
| packages/backend/test/unit/services/MoocletRewardsService.test.ts | Update expected reward summaries to new shape (no total, add prior/posterior fields). |
| packages/backend/test/unit/services/MoocletExperimentService.test.ts | Update tests for per-condition prior keyed by version IDs + version-condition maps. |
| packages/backend/src/api/services/MoocletRewardsService.ts | Fetch policy params for rewards summary and compute estimated Thompson weights. |
| packages/backend/src/api/services/MoocletExperimentService.ts | Translate prior/current_posteriors keys between conditionCodes and versionIds. |
Comments suppressed due to low confidence (1)
packages/frontend/projects/upgrade/src/app/core/experiments/mooclet-helper.service.ts:230
- Method naming is inconsistent with the rest of the service (
getTSConfigurableFieldValidators, etc.):getpriorFieldValidatorsshould begetPriorFieldValidators(and likewisecreatepriorForm/openEditConditionpriorModal, etc.). Keeping standard camelCase improves readability and avoids accidental mismatches in call sites.
/**
* Get field validators for per-condition prior success/failure inputs used in the prior editor.
*/
getpriorFieldValidators(): Record<string, ValidatorFn[]> {
const priorDefault = 1;
return {
successes: [
Validators.required,
Validators.min(priorDefault),
Validators.max(DEFAULT_MAX_NUMBER_INPUT),
CommonFormHelpersService.integerValidator(),
],
failures: [
Validators.required,
Validators.min(priorDefault),
Validators.max(DEFAULT_MAX_NUMBER_INPUT),
CommonFormHelpersService.integerValidator(),
],
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{ CONDITION_TRANSLATION_KEYS.prior_SUCCESSES | translate }} | ||
| </th> | ||
| <td mat-cell *matCellDef="let condition" class="prior-column ft-14-400"> | ||
| {{ getprioruccesses(condition) }} |
There was a problem hiding this comment.
Template references non-existent members: CONDITION_TRANSLATION_KEYS.prior_SUCCESSES and getprioruccesses(...) don't match the component (PRIOR_SUCCESSES and getPriorSuccesses). This will render blank headers / throw template errors at runtime/compile time. Update the template to use the correct constant key and method name.
| {{ CONDITION_TRANSLATION_KEYS.prior_SUCCESSES | translate }} | |
| </th> | |
| <td mat-cell *matCellDef="let condition" class="prior-column ft-14-400"> | |
| {{ getprioruccesses(condition) }} | |
| {{ CONDITION_TRANSLATION_KEYS.PRIOR_SUCCESSES | translate }} | |
| </th> | |
| <td mat-cell *matCellDef="let condition" class="prior-column ft-14-400"> | |
| {{ getPriorSuccesses(condition) }} |
There was a problem hiding this comment.
This still seems to be an issue, unless I'm looking at the wrong version of this branch.
|
hm, it's odd also that it's showing 100%-0%, that can't be right. sigh, i'll look, i'm thinking that I should back out the estimation part of this and aim it at dev when it's more ready, the priors stuff is the bugfix I shouldn't have shoehorned this in. |
|
(@bcb37 i am going to pull apart these things into different branches, so i set this in draft at the moment, will let you know) |


Apologies for giant PR, i got carried away
--
--
--

--