@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +9 -15
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +7 -6
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +12 -10
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +224 -52
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +99 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +98 -66
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +2 -2
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/experiments/config.js +8 -3
  59. package/dist/collections/experiments/deleteGuard.js +2 -2
  60. package/dist/collections/experiments/lockHook.js +21 -2
  61. package/dist/collections/experiments/pickSlug.js +2 -0
  62. package/dist/collections/metrics.js +12 -5
  63. package/dist/collections/metricsGuards.js +2 -0
  64. package/dist/collections/serialize.js +8 -6
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +1 -0
  67. package/dist/db/adapter.d.ts +9 -1
  68. package/dist/db/adapter.js +77 -1
  69. package/dist/db/delete.d.ts +1 -1
  70. package/dist/db/delete.js +2 -4
  71. package/dist/db/events.d.ts +9 -0
  72. package/dist/db/events.js +42 -8
  73. package/dist/db/executor.d.ts +7 -1
  74. package/dist/db/executor.js +7 -3
  75. package/dist/db/pageCopies.d.ts +5 -0
  76. package/dist/db/pageCopies.js +31 -0
  77. package/dist/db/results.d.ts +5 -1
  78. package/dist/db/results.js +21 -5
  79. package/dist/db/snapshots.d.ts +2 -0
  80. package/dist/endpoints/deleteImpact.js +2 -1
  81. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  82. package/dist/endpoints/duplicateOriginal.js +414 -0
  83. package/dist/endpoints/editorSurface.js +1 -1
  84. package/dist/endpoints/events.js +103 -39
  85. package/dist/endpoints/index.js +22 -8
  86. package/dist/endpoints/pages.js +245 -66
  87. package/dist/endpoints/placementStatus.js +8 -4
  88. package/dist/endpoints/results.d.ts +1 -1
  89. package/dist/endpoints/results.js +9 -2
  90. package/dist/endpoints/routeId.d.ts +2 -2
  91. package/dist/endpoints/routeId.js +11 -5
  92. package/dist/endpoints/summary.js +46 -12
  93. package/dist/endpoints/testVersion.d.ts +2 -0
  94. package/dist/endpoints/testVersion.js +38 -0
  95. package/dist/endpoints/transitions.js +41 -29
  96. package/dist/errors.d.ts +4 -0
  97. package/dist/errors.js +6 -0
  98. package/dist/events/request.d.ts +6 -2
  99. package/dist/events/request.js +35 -8
  100. package/dist/events/rows.d.ts +1 -1
  101. package/dist/events/rows.js +24 -8
  102. package/dist/events/writable.d.ts +9 -0
  103. package/dist/events/writable.js +13 -0
  104. package/dist/exports/index.d.ts +1 -1
  105. package/dist/exports/rsc.d.ts +1 -0
  106. package/dist/exports/rsc.js +1 -0
  107. package/dist/goals/fairness.js +2 -2
  108. package/dist/goals/picker/copy.js +1 -1
  109. package/dist/goals/sourceLabel.d.ts +2 -0
  110. package/dist/goals/sourceLabel.js +4 -0
  111. package/dist/hooks/hostHook.js +6 -2
  112. package/dist/hooks/pageGuard.js +4 -0
  113. package/dist/hooks/trackPageCopies.d.ts +11 -0
  114. package/dist/hooks/trackPageCopies.js +7 -0
  115. package/dist/labels/arms.d.ts +3 -0
  116. package/dist/labels/arms.js +8 -0
  117. package/dist/lib/fetchAllDocs.d.ts +1 -1
  118. package/dist/manifest/compile.js +8 -5
  119. package/dist/onInit.js +14 -0
  120. package/dist/options.d.ts +2 -0
  121. package/dist/options.js +23 -2
  122. package/dist/plugin.js +56 -2
  123. package/dist/proxy/pageNavigation.d.ts +4 -0
  124. package/dist/proxy/pageNavigation.js +28 -0
  125. package/dist/proxy/resolve.js +52 -25
  126. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  127. package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
  128. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  129. package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
  130. package/dist/puck/editor/LeftoverVersions.js +17 -32
  131. package/dist/puck/editor/QuickTestActions.d.ts +6 -3
  132. package/dist/puck/editor/QuickTestActions.js +55 -33
  133. package/dist/puck/editor/ResultsReadout.d.ts +4 -1
  134. package/dist/puck/editor/ResultsReadout.js +28 -15
  135. package/dist/puck/editor/VersionBuilder.d.ts +17 -4
  136. package/dist/puck/editor/VersionBuilder.js +175 -112
  137. package/dist/puck/editor/armWrites.js +2 -2
  138. package/dist/puck/editor/armsCache.js +1 -3
  139. package/dist/puck/editor/copy.d.ts +14 -7
  140. package/dist/puck/editor/copy.js +26 -13
  141. package/dist/puck/editor/editor.chrome.css +10 -8
  142. package/dist/puck/editor/editor.css +15 -9
  143. package/dist/puck/editor/editor.model.d.ts +1 -0
  144. package/dist/puck/editor/placementsCache.d.ts +4 -0
  145. package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
  146. package/dist/puck/editor/usePageSaveReadiness.js +31 -0
  147. package/dist/puck/nestedTestCopy.js +2 -2
  148. package/dist/puck/slotConfig.d.ts +1 -1
  149. package/dist/puck/slotConfig.js +1 -1
  150. package/dist/results/aggregate.d.ts +6 -3
  151. package/dist/results/aggregate.js +9 -9
  152. package/dist/results/analyse.d.ts +2 -0
  153. package/dist/results/analyse.js +2 -2
  154. package/dist/results/health.d.ts +8 -0
  155. package/dist/results/health.js +28 -0
  156. package/dist/results/identityCredit.d.ts +1 -0
  157. package/dist/results/identityCredit.js +4 -1
  158. package/dist/results/verdict.d.ts +4 -4
  159. package/dist/results/verdict.js +15 -11
  160. package/dist/runtime/cookie.d.ts +10 -2
  161. package/dist/runtime/cookie.js +38 -6
  162. package/dist/runtime/cookieOptions.d.ts +6 -0
  163. package/dist/runtime/cookieOptions.js +14 -0
  164. package/dist/runtime/proxyRuntime.d.ts +1 -0
  165. package/dist/runtime/proxyRuntime.js +18 -8
  166. package/dist/runtime/signing.d.ts +1 -0
  167. package/dist/runtime/signing.js +5 -0
  168. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  169. package/dist/sanitizeReadinessDetail.js +20 -2
  170. package/dist/server/getAssignments.js +11 -10
  171. package/dist/server/recordContentChange.d.ts +1 -1
  172. package/dist/server/recordContentChange.js +11 -2
  173. package/dist/server/resolveExperimentBlocks.js +2 -4
  174. package/dist/server/resolveExperimentData.js +2 -5
  175. package/dist/server/runResults.js +54 -15
  176. package/dist/server/startExperiment.d.ts +20 -0
  177. package/dist/server/startExperiment.js +70 -0
  178. package/dist/server/trackConversion.js +10 -13
  179. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  180. package/dist/testSurface/PreviewLinks.js +3 -3
  181. package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
  182. package/dist/testSurface/actions/DecideDialog.js +93 -63
  183. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  184. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  185. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  186. package/dist/testSurface/actions/MakeContentResult.js +10 -2
  187. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  188. package/dist/testSurface/actions/actions.model.js +75 -22
  189. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  190. package/dist/testSurface/actions/decide.model.js +1 -0
  191. package/dist/testSurface/allocation.model.js +6 -3
  192. package/dist/testSurface/api.d.ts +9 -6
  193. package/dist/testSurface/api.js +43 -23
  194. package/dist/testSurface/copy/actions.d.ts +37 -14
  195. package/dist/testSurface/copy/actions.js +40 -17
  196. package/dist/testSurface/copy/advanced.d.ts +10 -0
  197. package/dist/testSurface/copy/advanced.js +10 -0
  198. package/dist/testSurface/copy/arms.d.ts +1 -1
  199. package/dist/testSurface/copy/arms.js +1 -1
  200. package/dist/testSurface/copy/audience.d.ts +4 -3
  201. package/dist/testSurface/copy/audience.js +5 -4
  202. package/dist/testSurface/copy/common.d.ts +8 -6
  203. package/dist/testSurface/copy/common.js +8 -6
  204. package/dist/testSurface/copy/languages.d.ts +1 -0
  205. package/dist/testSurface/copy/languages.js +1 -0
  206. package/dist/testSurface/copy/metrics.d.ts +7 -0
  207. package/dist/testSurface/copy/metrics.js +9 -0
  208. package/dist/testSurface/copy/pages.d.ts +67 -7
  209. package/dist/testSurface/copy/pages.js +74 -7
  210. package/dist/testSurface/copy/readiness.d.ts +20 -7
  211. package/dist/testSurface/copy/readiness.js +36 -10
  212. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  213. package/dist/testSurface/copy/recommendation.js +2 -22
  214. package/dist/testSurface/copy/results.d.ts +21 -12
  215. package/dist/testSurface/copy/results.js +24 -13
  216. package/dist/testSurface/copy/review.d.ts +13 -10
  217. package/dist/testSurface/copy/review.js +14 -10
  218. package/dist/testSurface/copy/setting.d.ts +1 -2
  219. package/dist/testSurface/copy/setting.js +1 -2
  220. package/dist/testSurface/copy/surface.d.ts +11 -2
  221. package/dist/testSurface/copy/surface.js +14 -11
  222. package/dist/testSurface/copy/testPage.d.ts +36 -12
  223. package/dist/testSurface/copy/testPage.js +53 -16
  224. package/dist/testSurface/format/date.d.ts +5 -2
  225. package/dist/testSurface/format/date.js +24 -8
  226. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  227. package/dist/testSurface/format/roundProgress.js +15 -0
  228. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  229. package/dist/testSurface/format/useDateFormatter.js +8 -0
  230. package/dist/testSurface/labels.d.ts +1 -2
  231. package/dist/testSurface/labels.js +2 -3
  232. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  233. package/dist/testSurface/lockedNotice.model.js +31 -0
  234. package/dist/testSurface/readPreflight.d.ts +4 -0
  235. package/dist/testSurface/readPreflight.js +6 -0
  236. package/dist/testSurface/readinessRead.d.ts +3 -0
  237. package/dist/testSurface/readinessRead.js +4 -0
  238. package/dist/testSurface/results/CiChart.js +2 -1
  239. package/dist/testSurface/results/DataTable.d.ts +1 -1
  240. package/dist/testSurface/results/DataTable.js +4 -3
  241. package/dist/testSurface/results/VerdictHero.d.ts +3 -2
  242. package/dist/testSurface/results/VerdictHero.js +5 -1
  243. package/dist/testSurface/results/legacy.d.ts +0 -5
  244. package/dist/testSurface/results/legacy.js +0 -14
  245. package/dist/testSurface/results/results.css +2 -2
  246. package/dist/testSurface/results/results.model.d.ts +9 -4
  247. package/dist/testSurface/results/results.model.js +31 -23
  248. package/dist/testSurface/results/snapshot.d.ts +2 -0
  249. package/dist/testSurface/results/snapshot.js +3 -0
  250. package/dist/testSurface/surface/contracts.d.ts +13 -1
  251. package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
  252. package/dist/testSurface/surface/editorPlacement.js +2 -2
  253. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
  254. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  255. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  256. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  257. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  258. package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
  259. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  260. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  261. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  262. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
  263. package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
  264. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  265. package/dist/testSurface/surface/readiness/Banner.js +113 -141
  266. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
  267. package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
  268. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
  269. package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
  270. package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
  271. package/dist/testSurface/surface/readiness/useTransition.js +57 -14
  272. package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
  273. package/dist/testSurface/surface/results/ReleasePages.js +42 -41
  274. package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
  275. package/dist/testSurface/surface/results/ResultsBody.js +221 -118
  276. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  277. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  278. package/dist/testSurface/surface/results/useResults.d.ts +13 -8
  279. package/dist/testSurface/surface/results/useResults.js +3 -2
  280. package/dist/testSurface/surface/setting/parts.js +89 -46
  281. package/dist/testSurface/surface/setting/setting.css +2 -1
  282. package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
  283. package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
  284. package/dist/testSurface/surface/test/DeleteTest.js +173 -74
  285. package/dist/testSurface/surface/test/GoalSection.js +18 -14
  286. package/dist/testSurface/surface/test/LengthSection.js +24 -13
  287. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  288. package/dist/testSurface/surface/test/PageHoldout.js +11 -8
  289. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  290. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  291. package/dist/testSurface/surface/test/Section.js +8 -0
  292. package/dist/testSurface/surface/test/TargetingSection.js +82 -12
  293. package/dist/testSurface/surface/test/TestSurface.js +73 -37
  294. package/dist/testSurface/surface/test/VersionsSection.js +141 -91
  295. package/dist/testSurface/surface/test/fields.d.ts +32 -6
  296. package/dist/testSurface/surface/test/fields.js +166 -52
  297. package/dist/testSurface/surface/test/pageParts.js +27 -12
  298. package/dist/testSurface/surface/test/testPage.css +9 -2
  299. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  300. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  301. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  302. package/dist/testSurface/surface/testDocument.model.js +4 -1
  303. package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
  304. package/dist/testSurface/surface/useTestDocument.js +472 -167
  305. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  306. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  307. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  308. package/dist/testSurface/surfaceUrls.js +4 -0
  309. package/dist/testSurface/useApi.d.ts +8 -5
  310. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  311. package/dist/testSurface/useOnTestReturn.js +27 -0
  312. package/dist/testSurface/useReadinessPolling.js +3 -1
  313. package/dist/transitions/addMetric.d.ts +2 -5
  314. package/dist/transitions/addMetric.js +5 -1
  315. package/dist/transitions/allocate.d.ts +2 -2
  316. package/dist/transitions/allocate.js +3 -1
  317. package/dist/transitions/archive.d.ts +1 -1
  318. package/dist/transitions/archive.js +3 -2
  319. package/dist/transitions/checkStart.d.ts +1 -0
  320. package/dist/transitions/checkStart.js +17 -6
  321. package/dist/transitions/decide.d.ts +1 -1
  322. package/dist/transitions/decide.js +5 -3
  323. package/dist/transitions/deleteExperiment.d.ts +2 -2
  324. package/dist/transitions/deleteExperiment.js +17 -7
  325. package/dist/transitions/kernel.d.ts +4 -0
  326. package/dist/transitions/kernel.js +9 -4
  327. package/dist/transitions/makeContent.d.ts +2 -1
  328. package/dist/transitions/makeContent.js +12 -8
  329. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  330. package/dist/transitions/nestedPlacementNames.js +4 -5
  331. package/dist/transitions/pageAddress.d.ts +6 -0
  332. package/dist/transitions/pageAddress.js +71 -0
  333. package/dist/transitions/pageVersions.d.ts +1 -1
  334. package/dist/transitions/phaseRecord.d.ts +2 -0
  335. package/dist/transitions/phaseRecord.js +5 -0
  336. package/dist/transitions/placementInteractions.d.ts +3 -3
  337. package/dist/transitions/placementInteractions.js +8 -7
  338. package/dist/transitions/placements.d.ts +2 -0
  339. package/dist/transitions/placements.js +5 -5
  340. package/dist/transitions/preflightData.d.ts +3 -2
  341. package/dist/transitions/preflightData.js +77 -43
  342. package/dist/transitions/releaseHoldout.d.ts +2 -1
  343. package/dist/transitions/releaseHoldout.js +3 -1
  344. package/dist/transitions/releasePages.d.ts +2 -1
  345. package/dist/transitions/releasePages.js +3 -1
  346. package/dist/transitions/resolveCaps.d.ts +2 -4
  347. package/dist/transitions/start.d.ts +7 -9
  348. package/dist/transitions/start.js +75 -39
  349. package/dist/transitions/startReads.d.ts +7 -0
  350. package/dist/transitions/startReads.js +28 -0
  351. package/dist/transitions/stop.d.ts +2 -1
  352. package/dist/transitions/stop.js +3 -2
  353. package/dist/types/armKey.d.ts +2 -0
  354. package/dist/types/armKey.js +1 -0
  355. package/dist/types/contracts.d.ts +17 -4
  356. package/dist/types/endpoints.d.ts +89 -17
  357. package/dist/types/endpoints.js +1 -1
  358. package/dist/types/runtime.d.ts +15 -9
  359. package/dist/types/snapshot.d.ts +2 -0
  360. package/dist/types/surface.d.ts +7 -9
  361. package/dist/ui/ChipsInput.d.ts +8 -1
  362. package/dist/ui/ChipsInput.js +17 -4
  363. package/dist/ui/Dialog.d.ts +21 -2
  364. package/dist/ui/Dialog.js +101 -4
  365. package/dist/ui/Inputs.js +0 -1
  366. package/dist/ui/ui.css +5 -1
  367. package/package.json +2 -2
@@ -98,13 +98,6 @@
98
98
  gap: var(--xp-space-4);
99
99
  }
100
100
 
101
- .xp-slot-copy-confirm {
102
- padding: var(--xp-space-2) var(--xp-space-3);
103
- border: 1px solid var(--xp-warning);
104
- border-radius: var(--xp-radius);
105
- background: var(--xp-warning-surface);
106
- }
107
-
108
101
  /* Tailwind's preflight runs before these controls in the canvas document. */
109
102
  .xp-slot-editor .xp-ui-button,
110
103
  .xp-slot-editor .xp-ui-tab,
@@ -122,13 +115,21 @@
122
115
  .xp-slot-weight-inputs { align-items: flex-start; }
123
116
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
124
117
  .xp-slot-readout { display: grid; gap: var(--xp-space-2); }
125
- .xp-slot-readout > .xp-ui-button { justify-self: start; }
118
+ .xp-slot-readout-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: var(--xp-space-2); }
119
+ .xp-slot-readout-status { grid-column: 2; padding-block: var(--xp-space-2); font: var(--xp-text-small); }
120
+ .xp-slot-readout-refresh { grid-column: 3; }
121
+ .xp-slot-more { grid-column: 1; min-width: 0; }
122
+ .xp-slot-more > button { gap: var(--xp-space-2); }
123
+ .xp-slot-more > button[aria-expanded='true'] svg { transform: rotate(180deg); }
124
+ .xp-slot-more > div > button { white-space: normal; }
125
+ .xp-slot-lock-detail { margin: var(--xp-space-2) 0 0; }
126
126
  .xp-slot-editor .xp-ui-tablist { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
127
127
  .xp-slot-root.xp-puck-field { display: grid; gap: var(--xp-space-3); min-width: 0; }
128
128
 
129
129
  /* Puck's inline field sidebar stays light, including under Payload's dark-mode text overrides. */
130
130
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--secondary { color: var(--xp-text); }
131
131
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--primary { color: var(--xp-accent-fg); }
132
+ [class*="_PuckFields"] .xp-slot-root .xp-ui-button--danger { color: var(--xp-error); }
132
133
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
133
134
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
134
135
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
@@ -247,6 +248,7 @@
247
248
  .xp-slot-version-name .xp-ui-input { grid-area: 1 / 2; min-width: 0; font-weight: 600; }
248
249
  .xp-slot-version-traffic .xp-ui-input { grid-area: 1 / 3; min-width: 0; }
249
250
  .xp-slot-version-label { grid-area: 1 / 2 / auto / -1; align-self: center; min-width: 0; overflow-wrap: anywhere; }
251
+ .xp-slot-version-row .xp-field-draft-notice,
250
252
  .xp-slot-version-row .xp-ui-error { grid-column: 1 / -1; margin: 0; }
251
253
  /* Reserve one feedback line. Visibility preserves geometry between saves. */
252
254
  .xp-slot-version-saved { grid-column: 1 / -1; min-height: 16px; margin: 0; font: var(--xp-text-small); }
@@ -329,7 +329,8 @@
329
329
  .xp-ui-breadcrumb a:hover { color: var(--xp-text); }
330
330
  .xp-ui-breadcrumb [aria-current] { color: var(--xp-text); }
331
331
  .xp-ui-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 24px; border: 1px solid var(--xp-border); border-radius: var(--xp-radius-card); background: var(--xp-surface); color: var(--xp-text); font: var(--xp-text-body); box-shadow: 0 16px 48px var(--xp-overlay); }
332
- .xp-ui-dialog h2 { margin: 0 0 16px; font: var(--xp-text-title); }
332
+ .xp-ui-dialog h2 { margin: 0 0 16px; font: var(--xp-text-title); overflow-wrap: anywhere; }
333
+ .xp-ui-dialog > [id]:has(+ :is(.xp-ui-field, .xp-ui-banner)), .xp-ui-dialog > .xp-ui-banner:has(+ .xp-ui-field) { margin-block-end: var(--xp-space-4); }
333
334
  .xp-ui-dialog::backdrop { background: var(--xp-overlay); }
334
335
  .xp-ui-chips { width: 100%; max-width: 100%; min-width: 0; display: grid; gap: var(--xp-space-2); margin-block: var(--xp-space-4); color: var(--xp-text); font-family: var(--xp-font-body); }
335
336
  .xp-ui-chips-control { width: 100%; max-width: 100%; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-1); padding: var(--xp-space-2); border: 1px solid var(--xp-border-control); border-radius: var(--xp-radius); background: var(--xp-input-bg); }
@@ -345,6 +346,9 @@
345
346
  .xp-ui-chips p:not(.xp-ui-error) { margin: 0; color: var(--xp-text-muted); font-size: var(--xp-font-size-small); }
346
347
  /* Quiet actions and breadcrumb links stay neutral; only the selected tab takes the text accent. */
347
348
  .xp-ui-button-group { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; max-width: 100%; }
349
+ .xp-ui-confirm-actions { justify-content: flex-end; gap: var(--xp-space-2); margin-block-start: var(--xp-space-4); }
350
+ .xp-lifecycle-action { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--xp-space-1); min-width: 0; }
351
+ .xp-lifecycle-action > .xp-ui-help { margin: 0; max-width: 24ch; }
348
352
  .xp-ui-inline-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--xp-space-3); min-width: 0; }
349
353
  .xp-ui-inline-row > .xp-ui-field { flex: 1 1 auto; min-width: 0; }
350
354
  .xp-ui-inline-row > .xp-ui-button { flex: 0 0 auto; }
@@ -492,13 +496,6 @@
492
496
  gap: var(--xp-space-4);
493
497
  }
494
498
 
495
- .xp-slot-copy-confirm {
496
- padding: var(--xp-space-2) var(--xp-space-3);
497
- border: 1px solid var(--xp-warning);
498
- border-radius: var(--xp-radius);
499
- background: var(--xp-warning-surface);
500
- }
501
-
502
499
  /* Tailwind's preflight runs before these controls in the canvas document. */
503
500
  .xp-slot-editor .xp-ui-button,
504
501
  .xp-slot-editor .xp-ui-tab,
@@ -516,13 +513,21 @@
516
513
  .xp-slot-weight-inputs { align-items: flex-start; }
517
514
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
518
515
  .xp-slot-readout { display: grid; gap: var(--xp-space-2); }
519
- .xp-slot-readout > .xp-ui-button { justify-self: start; }
516
+ .xp-slot-readout-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: var(--xp-space-2); }
517
+ .xp-slot-readout-status { grid-column: 2; padding-block: var(--xp-space-2); font: var(--xp-text-small); }
518
+ .xp-slot-readout-refresh { grid-column: 3; }
519
+ .xp-slot-more { grid-column: 1; min-width: 0; }
520
+ .xp-slot-more > button { gap: var(--xp-space-2); }
521
+ .xp-slot-more > button[aria-expanded='true'] svg { transform: rotate(180deg); }
522
+ .xp-slot-more > div > button { white-space: normal; }
523
+ .xp-slot-lock-detail { margin: var(--xp-space-2) 0 0; }
520
524
  .xp-slot-editor .xp-ui-tablist { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
521
525
  .xp-slot-root.xp-puck-field { display: grid; gap: var(--xp-space-3); min-width: 0; }
522
526
 
523
527
  /* Puck's inline field sidebar stays light, including under Payload's dark-mode text overrides. */
524
528
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--secondary { color: var(--xp-text); }
525
529
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--primary { color: var(--xp-accent-fg); }
530
+ [class*="_PuckFields"] .xp-slot-root .xp-ui-button--danger { color: var(--xp-error); }
526
531
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
527
532
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
528
533
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
@@ -641,6 +646,7 @@
641
646
  .xp-slot-version-name .xp-ui-input { grid-area: 1 / 2; min-width: 0; font-weight: 600; }
642
647
  .xp-slot-version-traffic .xp-ui-input { grid-area: 1 / 3; min-width: 0; }
643
648
  .xp-slot-version-label { grid-area: 1 / 2 / auto / -1; align-self: center; min-width: 0; overflow-wrap: anywhere; }
649
+ .xp-slot-version-row .xp-field-draft-notice,
644
650
  .xp-slot-version-row .xp-ui-error { grid-column: 1 / -1; margin: 0; }
645
651
  /* Reserve one feedback line. Visibility preserves geometry between saves. */
646
652
  .xp-slot-version-saved { grid-column: 1 / -1; min-height: 16px; margin: 0; font: var(--xp-text-small); }
@@ -3,6 +3,7 @@ import type { ArmSlot } from '../../types/puck.js';
3
3
  import type { PreflightResult } from '../../types/endpoints.js';
4
4
  export type EditorExperiment = {
5
5
  name: string;
6
+ phase?: number;
6
7
  updatedAt?: string;
7
8
  status: Status;
8
9
  arms: Array<Pick<Arm, 'key' | 'kind' | 'label'> & Partial<Arm>>;
@@ -8,10 +8,12 @@ export declare function refreshPlacements(api: string, id: DocId, contentLocale?
8
8
  title: string;
9
9
  locales?: string[];
10
10
  allLocales?: true;
11
+ localeCodes?: string[];
11
12
  slotCount?: number;
12
13
  url?: string;
13
14
  editorUrl?: string;
14
15
  slots?: Record<import("../../types/puck.js").ArmSlot, number>;
16
+ partlyFilledSlots?: import("../../types/puck.js").ArmSlot[];
15
17
  ok: boolean;
16
18
  detail?: string;
17
19
  }[] | undefined>;
@@ -22,10 +24,12 @@ export declare function focusPlacements(api: string, id: DocId, contentLocale?:
22
24
  title: string;
23
25
  locales?: string[];
24
26
  allLocales?: true;
27
+ localeCodes?: string[];
25
28
  slotCount?: number;
26
29
  url?: string;
27
30
  editorUrl?: string;
28
31
  slots?: Record<import("../../types/puck.js").ArmSlot, number>;
32
+ partlyFilledSlots?: import("../../types/puck.js").ArmSlot[];
29
33
  ok: boolean;
30
34
  detail?: string;
31
35
  }[] | undefined>;
@@ -0,0 +1,6 @@
1
+ import type { DocId } from '../../types/contracts.js';
2
+ /** Listen for payload-puck 0.12.5+ save results through the DOM event. */
3
+ export declare function usePageSaveReadiness(api: string, id: DocId | undefined, page: {
4
+ collection: string;
5
+ id: string;
6
+ } | undefined, contentLocale?: string): void;
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+ import { invalidatePlacements } from './placementsCache.js';
4
+ const PUCK_SAVE_EVENT = 'payload-puck:save';
5
+ /** Listen for payload-puck 0.12.5+ save results through the DOM event. */ export function usePageSaveReadiness(api, id, page, contentLocale) {
6
+ const collection = page?.collection;
7
+ const pageId = page && String(page.id);
8
+ useEffect(()=>{
9
+ if (id === undefined || !collection || !pageId) return;
10
+ const onSave = (event)=>{
11
+ if (!(event instanceof CustomEvent)) return;
12
+ const detail = event.detail;
13
+ if (!detail || typeof detail !== 'object') return;
14
+ const save = detail;
15
+ if (save.ok !== true || save.id !== pageId || save.collection !== undefined && save.collection !== collection) return;
16
+ if (save.operation !== 'save' && save.operation !== 'publish' && save.operation !== 'unpublish') return;
17
+ if (typeof save.apiEndpoint !== 'string' || save.locale !== undefined && typeof save.locale !== 'string') return;
18
+ if (save.status !== undefined && save.status !== 'draft' && save.status !== 'published') return;
19
+ if (save.error !== undefined) return;
20
+ invalidatePlacements(api, id, contentLocale);
21
+ };
22
+ window.addEventListener(PUCK_SAVE_EVENT, onSave);
23
+ return ()=>window.removeEventListener(PUCK_SAVE_EVENT, onSave);
24
+ }, [
25
+ api,
26
+ id,
27
+ collection,
28
+ pageId,
29
+ contentLocale
30
+ ]);
31
+ }
@@ -1,4 +1,4 @@
1
- const innerLabel = (inner)=>inner ? `“${inner}”` : 'An Experiment block with no test chosen';
1
+ const innerLabel = (inner)=>inner ? `“${inner}”` : 'A Test block with no test chosen';
2
2
  const outerLabel = (outer)=>outer ? `“${outer}”` : 'another test';
3
3
  const moveLabel = (inner)=>inner ? `“${inner}”` : 'that block';
4
4
  const location = (outer, inner)=>`${innerLabel(inner)} is inside a version of ${outerLabel(outer)}.`;
@@ -8,7 +8,7 @@ export const nestedTestCopy = {
8
8
  start,
9
9
  readinessFallback,
10
10
  editor: (outer, inner)=>inner ? start(outer, inner) : `This test is inside a version of ${outerLabel(outer)}. A test can't go inside another test's version. Move this test out of that version before you start either test.`,
11
- publish: (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version, so this page can't be published. Move ${moveLabel(inner)} out of that version, then publish.`,
11
+ publish: (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version, so this page can't be published. Move ${moveLabel(inner)} out of that version to publish the page.`,
12
12
  hidden: (outer)=>`This test is inside a version of ${outerLabel(outer)}. It is hidden, so nothing is blocked now. If you show it again, the page can't be published until you move it out of that version.`,
13
13
  readiness: (detail)=>(Array.isArray(detail) && detail.length ? detail : [
14
14
  {}
@@ -1,5 +1,5 @@
1
1
  import type { ComponentConfig } from '@puckeditor/core';
2
2
  import { type ExperimentSlotProps } from '../types/puck.js';
3
- export declare const experimentSlotLabel = "Experiment block";
3
+ export declare const experimentSlotLabel = "Test block";
4
4
  export declare const experimentSlotFields: NonNullable<ComponentConfig<ExperimentSlotProps>['fields']>;
5
5
  export declare const experimentSlotDefaultProps: NonNullable<ComponentConfig<ExperimentSlotProps>['defaultProps']>;
@@ -1,7 +1,7 @@
1
1
  import { EXPERIMENT_SLOT_TYPE } from '../types/puck.js';
2
2
  import { createExperimentSlotField } from './experimentSlotField.js';
3
3
  import { slotLabels } from './copy.js';
4
- export const experimentSlotLabel = 'Experiment block';
4
+ export const experimentSlotLabel = 'Test block';
5
5
  export const experimentSlotFields = {
6
6
  experiment: createExperimentSlotField(),
7
7
  // Puck 0.24's defaultSlots prepends each slot, reversing declaration order in the outline.
@@ -2,11 +2,13 @@ export type Timestamp = Date | string | number;
2
2
  export interface ExposedUnit {
3
3
  arm: string;
4
4
  firstTs: Timestamp;
5
+ unitAgeMs?: number;
5
6
  }
6
7
  export interface MetricEvent {
7
8
  unitId: string;
8
9
  value: number;
9
10
  ts: Timestamp;
11
+ unitAgeMs?: number;
10
12
  }
11
13
  /** Accept Date, timestamp text, or epoch milliseconds; reject invalid dates. */
12
14
  export declare function timestampMs(ts: Timestamp): number;
@@ -17,18 +19,19 @@ export declare function firstExposures(rows: readonly {
17
19
  unitId: string;
18
20
  arm: string;
19
21
  ts: Timestamp;
22
+ unitAgeMs?: number;
20
23
  }[], { endedAt }?: {
21
24
  endedAt?: Timestamp;
22
25
  }): {
23
- units: Map<string, {
24
- arm: string;
26
+ units: Map<string, ExposedUnit & {
25
27
  firstTs: Date;
26
28
  }>;
27
29
  excludedMultiArm: number;
28
30
  };
29
31
  /** Spec §7.6/§8.2: zero-filled outcomes over each exposed unit's half-open window. */
30
- export declare function perUnitValues(units: ReadonlyMap<string, ExposedUnit>, events: readonly MetricEvent[], { kind, windowHours, endedAt }: {
32
+ export declare function perUnitValues(units: ReadonlyMap<string, ExposedUnit>, events: readonly MetricEvent[], { kind, windowHours, endedAt, onAttributed }: {
31
33
  kind: 'binomial' | 'count' | 'revenue';
32
34
  windowHours: number;
33
35
  endedAt?: Timestamp;
36
+ onAttributed?: (event: MetricEvent, ts: number) => void;
34
37
  }): Map<string, number>;
@@ -21,24 +21,23 @@ import { XpAnalysisError } from '../errors.js';
21
21
  const ts = timestampMs(row.ts);
22
22
  if (ts >= end || excluded.has(row.unitId)) continue;
23
23
  const unit = first.get(row.unitId);
24
- if (!unit) first.set(row.unitId, {
25
- arm: row.arm,
26
- firstTs: ts
27
- });
28
- else if (unit.arm !== row.arm) {
24
+ if (unit && unit.arm !== row.arm) {
29
25
  first.delete(row.unitId);
30
26
  excluded.add(row.unitId);
31
- } else if (ts < unit.firstTs) {
27
+ } else if (!unit || ts < unit.firstTs) {
32
28
  first.set(row.unitId, {
33
29
  arm: row.arm,
34
- firstTs: ts
30
+ firstTs: ts,
31
+ ...row.unitAgeMs === undefined ? {} : {
32
+ unitAgeMs: row.unitAgeMs
33
+ }
35
34
  });
36
35
  }
37
36
  }
38
37
  const units = new Map();
39
38
  for (const [unitId, unit] of first){
40
39
  units.set(unitId, {
41
- arm: unit.arm,
40
+ ...unit,
42
41
  firstTs: new Date(unit.firstTs)
43
42
  });
44
43
  }
@@ -47,7 +46,7 @@ import { XpAnalysisError } from '../errors.js';
47
46
  excludedMultiArm: excluded.size
48
47
  };
49
48
  }
50
- /** Spec §7.6/§8.2: zero-filled outcomes over each exposed unit's half-open window. */ export function perUnitValues(units, events, { kind, windowHours, endedAt }) {
49
+ /** Spec §7.6/§8.2: zero-filled outcomes over each exposed unit's half-open window. */ export function perUnitValues(units, events, { kind, windowHours, endedAt, onAttributed }) {
51
50
  const values = new Map();
52
51
  const starts = new Map();
53
52
  const duration = windowMs(windowHours);
@@ -61,6 +60,7 @@ import { XpAnalysisError } from '../errors.js';
61
60
  const start = starts.get(event.unitId);
62
61
  if (start === undefined) continue;
63
62
  if (ts < start || ts >= Math.min(start + duration, phaseEnd)) continue;
63
+ onAttributed?.(event, ts);
64
64
  values.set(event.unitId, kind === 'binomial' ? 1 : values.get(event.unitId) + (kind === 'count' ? 1 : event.value));
65
65
  }
66
66
  return values;
@@ -60,6 +60,8 @@ export interface MetricUnitData {
60
60
  }
61
61
  export type AnalysePhaseInput = {
62
62
  phase: AnalysisPhase;
63
+ /** The test's control can be absent from the two rollout arms. */
64
+ controlLabel?: string;
63
65
  /** The runner logs failures; injecting this keeps analysis free of I/O imports. */
64
66
  onMetricError?: (error: unknown, metricId: DocId) => void;
65
67
  status: 'running' | 'stopped' | 'decided';
@@ -7,7 +7,7 @@ import { guardrailStatus } from './guardrails.js';
7
7
  import { remainingPower } from './power.js';
8
8
  import { assembleSnapshot, jsonInterval } from './snapshot.js';
9
9
  import { exposureSrm } from './srm.js';
10
- import { computeVerdict } from './verdict.js';
10
+ import { computeVerdict, verdictGroupLabel } from './verdict.js';
11
11
  const severity = {
12
12
  ok: 0,
13
13
  insufficient: 1,
@@ -341,7 +341,7 @@ const severity = {
341
341
  guardrails: verdictGuardrails,
342
342
  power,
343
343
  plannedDurationPassed: to - from >= analysis.plannedDurationDays * 86_400_000,
344
- originalLabel: phase.arms.find((arm)=>arm.kind === 'control')?.label ?? 'Original',
344
+ originalLabel: verdictGroupLabel('control', input.controlLabel ?? phase.arms.find((arm)=>arm.kind === 'control')?.label),
345
345
  controlArm: baselineArm.key
346
346
  };
347
347
  const verdictInput = rollout ? {
@@ -1,4 +1,12 @@
1
1
  import type { Snapshot, SnapshotHealth } from '../types/snapshot.js';
2
+ /** A diagnostic for a large difference in rapid activity, not an inference test.
3
+ * Compare only arms with enough observations and age coverage. Ordinary
4
+ * same-speed activity (including immediate pageviews) should not warn.
5
+ */
6
+ export declare function rapidBrowserEvents(arms: ReadonlySet<string>, units: Iterable<{
7
+ arm: string;
8
+ unitAgeMs?: number;
9
+ }>): boolean;
2
10
  /** Refresh page health while retaining health produced by other checks. */
3
11
  export declare function mergePageHealth(previous: readonly SnapshotHealth[], pages: readonly SnapshotHealth[]): SnapshotHealth[];
4
12
  export declare function canonicalHealth(snapshot: Pick<Snapshot, 'health' | 'goalFairnessNotice'>, ignoreUncheckedPlacements?: boolean): string;
@@ -1,3 +1,31 @@
1
+ const rapidAgeMs = 5_000;
2
+ const minimumKnownPerArm = 30;
3
+ /** A diagnostic for a large difference in rapid activity, not an inference test.
4
+ * Compare only arms with enough observations and age coverage. Ordinary
5
+ * same-speed activity (including immediate pageviews) should not warn.
6
+ */ export function rapidBrowserEvents(arms, units) {
7
+ const counts = new Map();
8
+ for (const { arm, unitAgeMs } of units){
9
+ if (!arms.has(arm)) continue;
10
+ const count = counts.get(arm) ?? {
11
+ total: 0,
12
+ known: 0,
13
+ rapid: 0
14
+ };
15
+ count.total++;
16
+ if (unitAgeMs !== undefined) {
17
+ count.known++;
18
+ if (unitAgeMs <= rapidAgeMs) count.rapid++;
19
+ }
20
+ counts.set(arm, count);
21
+ }
22
+ const usable = [
23
+ ...counts.values()
24
+ ].filter((count)=>count.known >= minimumKnownPerArm && 2 * count.known >= count.total);
25
+ // A fast arm needs ≥25% rapid activity and a gap of ≥20 percentage points.
26
+ // Compare counts directly so exact boundaries don't depend on rounding.
27
+ return usable.some((high)=>4 * high.rapid >= high.known && usable.some((low)=>5 * (high.rapid * low.known - low.rapid * high.known) >= high.known * low.known));
28
+ }
1
29
  const healthKey = (row)=>JSON.stringify(row.code === 'placement-unchecked' ? [
2
30
  row.code,
3
31
  row.detail.collection ?? '',
@@ -18,6 +18,7 @@ export declare function creditUserEvents(units: ReadonlyMap<string, ExposedUnit>
18
18
  userId: string;
19
19
  value: number;
20
20
  ts: Timestamp;
21
+ unitAgeMs?: number;
21
22
  }[], onConflict?: (userId: string) => void): {
22
23
  events: MetricEvent[];
23
24
  conflicts: number;
@@ -31,7 +31,10 @@ import { timestampMs } from './aggregate.js';
31
31
  events.push({
32
32
  unitId: eligible[0].anonymousId,
33
33
  value: event.value,
34
- ts: event.ts
34
+ ts: event.ts,
35
+ ...event.unitAgeMs === undefined ? {} : {
36
+ unitAgeMs: event.unitAgeMs
37
+ }
35
38
  });
36
39
  if (new Set(eligible.map((link)=>units.get(link.anonymousId).arm)).size > 1) {
37
40
  conflicts.add(event.userId);
@@ -66,20 +66,20 @@ interface VerdictInputFields {
66
66
  status: 'ok' | 'warning' | 'insufficient';
67
67
  worstArmLabel?: string;
68
68
  })>;
69
- /** Additional days needed, rounded up by CORE-15a: 0 = already enough data,
70
- * null = unknown. Infeasible or >90 days uses the long-duration copy; positive
71
- * days use an estimate; 0/null with feasible=true runs to the planned end date. */
69
+ /** Additional days needed: 0 = already enough data, null = unknown.
70
+ * Infeasible or >90 days uses the long-duration copy. */
72
71
  power: {
73
72
  daysRemaining: number | null;
74
73
  feasible: boolean;
75
74
  };
76
75
  plannedDurationPassed: boolean;
77
- /** Reserved for future use; "the Original" remains literal UI vocabulary. */
76
+ /** The frozen label of the test's control version, including for rollouts. */
78
77
  originalLabel: string;
79
78
  controlArm: string;
80
79
  }
81
80
  /** Resolve a stored group label without exposing an internal key in verdict copy. */
82
81
  export declare function verdictGroupLabel(key: string, label?: string): string;
82
+ export declare function isLongDuration({ feasible, daysRemaining }: VerdictInput['power']): boolean;
83
83
  /** Apply spec §8.5 in order to already-computed results; no inference is performed here. */
84
84
  export declare function computeVerdict(input: VerdictInput): Snapshot['verdict'];
85
85
  export {};
@@ -1,4 +1,5 @@
1
1
  import { ARM_LABELS } from '../labels/arms.js';
2
+ import { RESULTS_COPY } from '../testSurface/copy/results.js';
2
3
  function percent(value) {
3
4
  if (value === null) return '…';
4
5
  const rounded = Math.round(value * 100);
@@ -23,8 +24,12 @@ function chance(value) {
23
24
  /** Resolve a stored group label without exposing an internal key in verdict copy. */ export function verdictGroupLabel(key, label = '') {
24
25
  return label.trim() || (Object.hasOwn(ARM_LABELS, key) ? ARM_LABELS[key] : 'This group');
25
26
  }
27
+ export function isLongDuration({ feasible, daysRemaining }) {
28
+ return !feasible || daysRemaining !== null && daysRemaining > 90;
29
+ }
26
30
  /** Apply spec §8.5 in order to already-computed results; no inference is performed here. */ export function computeVerdict(input) {
27
31
  const rollout = input.phaseKind === 'rollout';
32
+ const controlLabel = input.originalLabel;
28
33
  const make = (row, code, finding, action, detail, recommendedArm, line, worstArm)=>({
29
34
  row,
30
35
  code,
@@ -44,7 +49,7 @@ function chance(value) {
44
49
  return make(rollout ? 'R1' : 1, 'unavailable', `Results unavailable: ${input.primary.name} could not be read.`, 'Recompute; if it persists, contact a developer.', 'The main outcome could not be loaded.', null);
45
50
  }
46
51
  if (input.srm.flagged || input.exposures.multiArmShare >= 0.01) {
47
- return make(rollout ? 'R1' : 2, 'data-problem', "Data problem: traffic isn't splitting as set.", "Don't trust these results. Check for caching or a page placed twice; contact a developer.", 'The people counted do not match the expected split.', null);
52
+ return make(rollout ? 'R1' : 2, 'data-problem', "Data problem: traffic isn't splitting as set.", input.srm.flagged ? RESULTS_COPY.srmAction : "Don't trust these results. Ask a developer to check for caching or a page placed twice.", 'The people counted do not match the expected split.', null);
48
53
  }
49
54
  const compared = input.exposures.perArm.filter((item)=>rollout || item.kind !== 'holdout');
50
55
  const minimum = compared.length ? Math.min(...compared.map((item)=>item.n)) : 0;
@@ -60,7 +65,7 @@ function chance(value) {
60
65
  null,
61
66
  null
62
67
  ];
63
- return make('R3', 'rollout-readout', `Since shipping ${winner}: ${percent(lift)} vs the holdout (CI ${percent(ci[0])} to ${percent(ci[1])}).`, null, 'This describes the shipped version compared with people still seeing the Original.', null, guardrailLine(input));
68
+ return make('R3', 'rollout-readout', `Since shipping ${winner}: ${percent(lift)} vs the holdout (CI ${percent(ci[0])} to ${percent(ci[1])}).`, null, `This describes the shipped version compared with people still seeing ${controlLabel}.`, null, guardrailLine(input));
64
69
  }
65
70
  const failing = input.guardrails.find((item)=>item.status === 'failing');
66
71
  if (failing) return make(3, 'guardrail-failing', `Stop: ${failing.worstArmLabel} harms ${failing.name}.`, null, 'An outcome that must stay safe has become worse.', input.controlArm, undefined, failing.worstArm);
@@ -68,7 +73,7 @@ function chance(value) {
68
73
  const smallest = compared.find((item)=>item.n === minimum);
69
74
  const fewest = converters.find((item)=>item.converters === minimumConverters);
70
75
  const groupLabel = (group)=>{
71
- if (!group || group.kind === 'control') return 'Original';
76
+ if (!group || group.kind === 'control') return controlLabel;
72
77
  const label = input.exposures.perArm.find((item)=>item.arm === group.arm)?.label ?? input.primary.comparisons.find((item)=>item.arm === group.arm)?.label;
73
78
  return verdictGroupLabel(group.arm, label);
74
79
  };
@@ -87,19 +92,18 @@ function chance(value) {
87
92
  ...better
88
93
  ].sort((a, b)=>direction * (b.lift - a.lift))[0];
89
94
  const worst = worse[0];
90
- if (variants.length > 0 && worse.length === variants.length) return make(5, 'original-better', 'The Original is better.', 'Decide for the Original.', 'Every tested alternative performed worse.', input.controlArm);
91
- if (worst && !best) return make(6, 'worse-none-better', `${labels(worse)} ${worse.length === 1 ? 'is' : 'are'} worse; no variant is better.`, `Decide for the Original or restart without ${worse.length === 1 ? 'it' : 'them'}.`, 'At least one alternative performed worse and none improved the main outcome.', input.controlArm, undefined, worst.arm);
95
+ if (variants.length > 0 && worse.length === variants.length) return make(5, 'original-better', `${controlLabel} is better.`, `Decide for ${controlLabel}.`, 'Every tested alternative performed worse.', input.controlArm);
96
+ if (worst && !best) return make(6, 'worse-none-better', `${labels(worse)} ${worse.length === 1 ? 'is' : 'are'} worse; no variant is better.`, `Decide for ${controlLabel} or restart without ${worse.length === 1 ? 'it' : 'them'}.`, 'At least one alternative performed worse and none improved the main outcome.', input.controlArm, undefined, worst.arm);
92
97
  if (best && !worst) {
93
- const finding = better.length >= 2 ? `${better.length === 2 ? 'Both' : `All ${better.length} variants`} beat the Original; not tested against each other — ${best.label} has the larger improvement.` : input.method === 'bayesian' ? `${best.label} is very likely better${chance(best.chanceToWin)}.` : `${best.label} is statistically better: ${percent(best.lift)} (CI ${percent(best.ci[0])} to ${percent(best.ci[1])}).`;
94
- return make(7, 'winner', finding, null, 'The main outcome improved compared with the Original.', best.arm, guardrailLine(input));
98
+ const finding = better.length >= 2 ? `${better.length === 2 ? 'Both' : `All ${better.length} variants`} beat ${controlLabel}; not tested against each other — ${best.label} has the larger improvement.` : input.method === 'bayesian' ? `${best.label} is very likely better${chance(best.chanceToWin)}.` : `${best.label} is statistically better: ${percent(best.lift)} (CI ${percent(best.ci[0])} to ${percent(best.ci[1])}).`;
99
+ return make(7, 'winner', finding, null, `The main outcome improved compared with ${controlLabel}.`, best.arm, guardrailLine(input));
95
100
  }
96
101
  if (best && worst) return make(8, 'mixed', `Mixed: ${labels(better)} better, ${labels(worse)} worse.`, 'Review before deciding.', 'The tested alternatives moved the main outcome in different directions.', best.arm, undefined, worst.arm);
97
102
  if (input.status === 'running' && !input.plannedDurationPassed) {
98
- if (input.power.feasible === false || input.power.daysRemaining !== null && input.power.daysRemaining > 90) {
99
- return make(9, 'keep-running', 'A clear answer would take more than 90 days at this traffic.', 'Consider a bigger change or a different metric.', 'Current traffic is too low for a timely answer.', null);
103
+ if (isLongDuration(input.power)) {
104
+ return make(9, 'keep-running', RESULTS_COPY.infeasible, 'Consider a bigger change or a different metric.', 'Current traffic is too low for a timely answer.', null);
100
105
  }
101
- const action = input.power.daysRemaining !== null && input.power.daysRemaining >= 1 ? `Keep running about ${Math.ceil(input.power.daysRemaining)} days.` : 'Keep running to the planned end date.';
102
- return make(9, 'keep-running', 'No clear winner yet.', action, 'The current results do not yet distinguish the tested versions.', null);
106
+ return make(9, 'keep-running', 'No clear winner yet.', RESULTS_COPY.plannedEnd, 'The current results do not yet distinguish the tested versions.', null);
103
107
  }
104
108
  return make(10, 'no-difference', 'No detectable difference at this size.', null, 'The data collected did not show a clear improvement or decline.', input.controlArm);
105
109
  }
@@ -1,10 +1,17 @@
1
1
  import { NextRequest } from 'next/server.js';
2
2
  import type { ExperimentsProxyRuntime } from '../types/runtime.js';
3
3
  export declare function mintUnitId(): string;
4
- export declare function encodeUnitCookie(unitId: string, secrets: readonly string[]): string;
5
- export declare function verifyUnitCookie(cookie: string | undefined, secrets: readonly string[]): string | null;
4
+ export declare function encodeUnitCookie(unitId: string, secrets: readonly string[], issuedAtMs?: number | 'legacy', renewedAtMs?: number): string;
5
+ interface SignedUnit {
6
+ unitId: string;
7
+ issuedAtMs: number | 'legacy';
8
+ renewedAtMs: number | null;
9
+ }
10
+ export declare function verifySignedUnit(cookie: string | undefined, secrets: readonly string[], maxAgeMs: number, now?: number, legacyCutoffMs?: number): SignedUnit | null;
11
+ export declare function unitCookieMaxAgeMs(runtime: Pick<ExperimentsProxyRuntime, 'cookie'>): number;
6
12
  /** Use Next's cookie selection everywhere: the last cookie of a given name wins. */
7
13
  export declare function readUnitCookie(input: Headers | NextRequest, runtime: Pick<ExperimentsProxyRuntime, 'cookie' | 'secrets'>): string | null;
14
+ export declare function readSignedUnit(input: Headers | NextRequest, runtime: Pick<ExperimentsProxyRuntime, 'cookie' | 'secrets'>, now?: number): SignedUnit | null;
8
15
  export declare function cookieAttributes(runtime: Pick<ExperimentsProxyRuntime, 'cookie'>, { https }: {
9
16
  https: boolean;
10
17
  }): {
@@ -15,3 +22,4 @@ export declare function cookieAttributes(runtime: Pick<ExperimentsProxyRuntime,
15
22
  path: string;
16
23
  maxAge: number;
17
24
  };
25
+ export {};
@@ -1,30 +1,62 @@
1
1
  import { randomBytes } from 'node:crypto';
2
2
  import { NextRequest } from 'next/server.js';
3
+ import { DAY_MS, LEGACY_COOKIE_CUTOFF_MS } from './cookieOptions.js';
3
4
  import { sign, verify } from './signing.js';
4
5
  export function mintUnitId() {
5
6
  return randomBytes(16).toString('base64url');
6
7
  }
7
- export function encodeUnitCookie(unitId, secrets) {
8
+ export function encodeUnitCookie(unitId, secrets, issuedAtMs = Date.now(), renewedAtMs = issuedAtMs === 'legacy' ? Date.now() : issuedAtMs) {
8
9
  if (!/^[A-Za-z0-9_-]+$/.test(unitId)) throw new Error('Invalid unit id');
9
- return `${unitId}.${sign(`xp:unit:${unitId}`, secrets)}`;
10
+ if (!validTimes(issuedAtMs, renewedAtMs)) throw new Error('Invalid unit cookie time');
11
+ const payload = `${unitId}.${issuedAtMs}.${renewedAtMs}`;
12
+ return `v2.${payload}.${sign(`xp:unit:v2:${payload}`, secrets)}`;
10
13
  }
11
- export function verifyUnitCookie(cookie, secrets) {
14
+ function validTimes(issuedAtMs, renewedAtMs) {
15
+ return Number.isSafeInteger(renewedAtMs) && renewedAtMs >= 0 && (issuedAtMs === 'legacy' || Number.isSafeInteger(issuedAtMs) && issuedAtMs >= 0 && issuedAtMs <= renewedAtMs);
16
+ }
17
+ export function verifySignedUnit(cookie, secrets, maxAgeMs, now = Date.now(), legacyCutoffMs = LEGACY_COOKIE_CUTOFF_MS) {
12
18
  if (typeof cookie !== 'string') return null;
19
+ const acceptsLegacy = now < Math.min(legacyCutoffMs, LEGACY_COOKIE_CUTOFF_MS);
20
+ const timed = /^v2\.(([A-Za-z0-9_-]+)\.(legacy|0|[1-9][0-9]{0,15})\.(0|[1-9][0-9]{0,15}))\.([A-Za-z0-9_-]{43})$/.exec(cookie);
21
+ if (timed) {
22
+ const payload = timed[1], unitId = timed[2], time = timed[3], renewal = timed[4], mac = timed[5];
23
+ const issuedAtMs = time === 'legacy' ? time : Number(time);
24
+ const renewedAtMs = Number(renewal);
25
+ if (issuedAtMs === 'legacy' && !acceptsLegacy) return null;
26
+ return validTimes(issuedAtMs, renewedAtMs) && now - renewedAtMs < maxAgeMs && verify(`xp:unit:v2:${payload}`, mac, secrets) ? {
27
+ unitId,
28
+ issuedAtMs,
29
+ renewedAtMs
30
+ } : null;
31
+ }
32
+ if (!acceptsLegacy) return null;
13
33
  const match = /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/.exec(cookie);
14
- return match && verify(`xp:unit:${match[1]}`, match[2], secrets) ? match[1] : null;
34
+ return match && verify(`xp:unit:${match[1]}`, match[2], secrets) ? {
35
+ unitId: match[1],
36
+ issuedAtMs: 'legacy',
37
+ renewedAtMs: null
38
+ } : null;
39
+ }
40
+ export function unitCookieMaxAgeMs(runtime) {
41
+ // Set-Cookie's Max-Age is an integer number of seconds. Verify the same lifetime.
42
+ return Math.floor(runtime.cookie.maxAgeDays * (DAY_MS / 1000)) * 1000;
15
43
  }
16
44
  /** Use Next's cookie selection everywhere: the last cookie of a given name wins. */ export function readUnitCookie(input, runtime) {
45
+ return readSignedUnit(input, runtime)?.unitId ?? null;
46
+ }
47
+ export function readSignedUnit(input, runtime, now = Date.now()) {
17
48
  const request = input instanceof Headers ? new NextRequest('https://xp.invalid/', {
18
49
  headers: input
19
50
  }) : input;
20
- return verifyUnitCookie(request.cookies.get(runtime.cookie.name)?.value, runtime.secrets);
51
+ const cutoff = runtime.cookie.legacyCutoff;
52
+ return verifySignedUnit(request.cookies.get(runtime.cookie.name)?.value, runtime.secrets, unitCookieMaxAgeMs(runtime), now, cutoff === undefined ? undefined : Date.parse(cutoff));
21
53
  }
22
54
  export function cookieAttributes(runtime, { https }) {
23
55
  return {
24
56
  httpOnly: true,
25
57
  sameSite: 'lax',
26
58
  path: '/',
27
- maxAge: runtime.cookie.maxAgeDays * 86400,
59
+ maxAge: unitCookieMaxAgeMs(runtime) / 1000,
28
60
  ...https ? {
29
61
  secure: true
30
62
  } : {},
@@ -0,0 +1,6 @@
1
+ export declare const LEGACY_COOKIE_CUTOFF_MS: number;
2
+ export declare const DAY_MS = 86400000;
3
+ export declare function assertCookieOptions({ maxAgeDays, legacyCutoff }: {
4
+ maxAgeDays: number;
5
+ legacyCutoff?: string;
6
+ }): void;
@@ -0,0 +1,14 @@
1
+ // 400 days after the end of the December 2, 2026 rollout day (UTC).
2
+ export const LEGACY_COOKIE_CUTOFF_MS = Date.UTC(2028, 0, 7);
3
+ export const DAY_MS = 86_400_000;
4
+ export function assertCookieOptions({ maxAgeDays, legacyCutoff }) {
5
+ if (!Number.isFinite(maxAgeDays) || maxAgeDays * DAY_MS < 1000 || maxAgeDays > 400) {
6
+ throw new Error('Experiments cookie.maxAgeDays must be a number from one second in days (1/86400) through 400.');
7
+ }
8
+ if (legacyCutoff !== undefined) {
9
+ const cutoff = typeof legacyCutoff === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(legacyCutoff) ? Date.parse(legacyCutoff) : NaN;
10
+ if (!Number.isFinite(cutoff) || cutoff > LEGACY_COOKIE_CUTOFF_MS || new Date(cutoff).toISOString().slice(0, 10) !== legacyCutoff) {
11
+ throw new Error('Experiments cookie.legacyCutoff must be a UTC date (YYYY-MM-DD) on or before 2028-01-07.');
12
+ }
13
+ }
14
+ }
@@ -1,2 +1,3 @@
1
1
  import type { ExperimentsProxyRuntime, ExperimentsProxyRuntimeOptions } from '../types/runtime.js';
2
+ export declare function assertUnitRateLimit(rateLimitUnit: unknown): void;
2
3
  export declare function defineExperimentsProxyRuntime(opts: ExperimentsProxyRuntimeOptions): ExperimentsProxyRuntime;