@memberjunction/predictive-studio 6.2.0 → 6.3.0-edge.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 (390) hide show
  1. package/README.md +16 -11
  2. package/dist/actions/base-predictive-studio.action.d.ts +7 -0
  3. package/dist/actions/base-predictive-studio.action.d.ts.map +1 -1
  4. package/dist/actions/base-predictive-studio.action.js +22 -0
  5. package/dist/actions/base-predictive-studio.action.js.map +1 -1
  6. package/dist/actions/driver-classes.d.ts +2 -0
  7. package/dist/actions/driver-classes.d.ts.map +1 -1
  8. package/dist/actions/driver-classes.js +2 -0
  9. package/dist/actions/driver-classes.js.map +1 -1
  10. package/dist/actions/evaluate-drift.action.d.ts +100 -0
  11. package/dist/actions/evaluate-drift.action.d.ts.map +1 -0
  12. package/dist/actions/evaluate-drift.action.js +512 -0
  13. package/dist/actions/evaluate-drift.action.js.map +1 -0
  14. package/dist/actions/index.d.ts +3 -0
  15. package/dist/actions/index.d.ts.map +1 -1
  16. package/dist/actions/index.js +7 -0
  17. package/dist/actions/index.js.map +1 -1
  18. package/dist/actions/migrate-pipelines.action.d.ts +19 -0
  19. package/dist/actions/migrate-pipelines.action.d.ts.map +1 -0
  20. package/dist/actions/migrate-pipelines.action.js +51 -0
  21. package/dist/actions/migrate-pipelines.action.js.map +1 -0
  22. package/dist/actions/promote-model.action.d.ts +12 -1
  23. package/dist/actions/promote-model.action.d.ts.map +1 -1
  24. package/dist/actions/promote-model.action.js +7 -2
  25. package/dist/actions/promote-model.action.js.map +1 -1
  26. package/dist/actions/promote-model.gate.d.ts +31 -2
  27. package/dist/actions/promote-model.gate.d.ts.map +1 -1
  28. package/dist/actions/promote-model.gate.js +84 -5
  29. package/dist/actions/promote-model.gate.js.map +1 -1
  30. package/dist/actions/run-experiment.action.d.ts.map +1 -1
  31. package/dist/actions/run-experiment.action.js +5 -4
  32. package/dist/actions/run-experiment.action.js.map +1 -1
  33. package/dist/actions/schedule-model-scoring.action.js +2 -2
  34. package/dist/actions/schedule-model-scoring.action.js.map +1 -1
  35. package/dist/actions/score-record-set.action.js +1 -1
  36. package/dist/actions/score-record-set.action.js.map +1 -1
  37. package/dist/actions/score-record-set.runner.d.ts +2 -2
  38. package/dist/actions/score-record-set.runner.js +3 -3
  39. package/dist/actions/score-record-set.runner.js.map +1 -1
  40. package/dist/actions/train-model.action.d.ts +28 -25
  41. package/dist/actions/train-model.action.d.ts.map +1 -1
  42. package/dist/actions/train-model.action.js +50 -39
  43. package/dist/actions/train-model.action.js.map +1 -1
  44. package/dist/agent/index.d.ts +1 -1
  45. package/dist/agent/index.js +1 -1
  46. package/dist/agent/modeling-plan-to-pipeline.d.ts +0 -2
  47. package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -1
  48. package/dist/agent/modeling-plan-to-pipeline.js +30 -39
  49. package/dist/agent/modeling-plan-to-pipeline.js.map +1 -1
  50. package/dist/agent/pipeline-builder-agent.d.ts +47 -18
  51. package/dist/agent/pipeline-builder-agent.d.ts.map +1 -1
  52. package/dist/agent/pipeline-builder-agent.js +161 -92
  53. package/dist/agent/pipeline-builder-agent.js.map +1 -1
  54. package/dist/agent/pipeline-builder.d.ts +178 -56
  55. package/dist/agent/pipeline-builder.d.ts.map +1 -1
  56. package/dist/agent/pipeline-builder.js +333 -234
  57. package/dist/agent/pipeline-builder.js.map +1 -1
  58. package/dist/experiment/budget.d.ts +61 -0
  59. package/dist/experiment/budget.d.ts.map +1 -0
  60. package/dist/experiment/budget.js +72 -0
  61. package/dist/experiment/budget.js.map +1 -0
  62. package/dist/experiment/experiment-orchestrator.d.ts +43 -7
  63. package/dist/experiment/experiment-orchestrator.d.ts.map +1 -1
  64. package/dist/experiment/experiment-orchestrator.js +130 -33
  65. package/dist/experiment/experiment-orchestrator.js.map +1 -1
  66. package/dist/experiment/index.d.ts +2 -0
  67. package/dist/experiment/index.d.ts.map +1 -1
  68. package/dist/experiment/index.js +2 -0
  69. package/dist/experiment/index.js.map +1 -1
  70. package/dist/experiment/leaderboard.d.ts +15 -15
  71. package/dist/experiment/leaderboard.d.ts.map +1 -1
  72. package/dist/experiment/leaderboard.js +44 -18
  73. package/dist/experiment/leaderboard.js.map +1 -1
  74. package/dist/experiment/scores.d.ts +32 -0
  75. package/dist/experiment/scores.d.ts.map +1 -0
  76. package/dist/experiment/scores.js +62 -0
  77. package/dist/experiment/scores.js.map +1 -0
  78. package/dist/experiment/seams.d.ts +23 -20
  79. package/dist/experiment/seams.d.ts.map +1 -1
  80. package/dist/experiment/seams.js +54 -56
  81. package/dist/experiment/seams.js.map +1 -1
  82. package/dist/experiment/types.d.ts +55 -10
  83. package/dist/experiment/types.d.ts.map +1 -1
  84. package/dist/experiment/types.js.map +1 -1
  85. package/dist/feature-assembly/as-of/as-of-assembler.d.ts +412 -0
  86. package/dist/feature-assembly/as-of/as-of-assembler.d.ts.map +1 -0
  87. package/dist/feature-assembly/as-of/as-of-assembler.js +1239 -0
  88. package/dist/feature-assembly/as-of/as-of-assembler.js.map +1 -0
  89. package/dist/feature-assembly/as-of/feature-resolution.d.ts +84 -0
  90. package/dist/feature-assembly/as-of/feature-resolution.d.ts.map +1 -0
  91. package/dist/feature-assembly/as-of/feature-resolution.js +229 -0
  92. package/dist/feature-assembly/as-of/feature-resolution.js.map +1 -0
  93. package/dist/feature-assembly/as-of/index.d.ts +15 -0
  94. package/dist/feature-assembly/as-of/index.d.ts.map +1 -0
  95. package/dist/feature-assembly/as-of/index.js +15 -0
  96. package/dist/feature-assembly/as-of/index.js.map +1 -0
  97. package/dist/feature-assembly/as-of/read-by-keys.d.ts +30 -0
  98. package/dist/feature-assembly/as-of/read-by-keys.d.ts.map +1 -0
  99. package/dist/feature-assembly/as-of/read-by-keys.js +51 -0
  100. package/dist/feature-assembly/as-of/read-by-keys.js.map +1 -0
  101. package/dist/feature-assembly/as-of/record-history.d.ts +256 -0
  102. package/dist/feature-assembly/as-of/record-history.d.ts.map +1 -0
  103. package/dist/feature-assembly/as-of/record-history.js +505 -0
  104. package/dist/feature-assembly/as-of/record-history.js.map +1 -0
  105. package/dist/feature-assembly/as-of/refusal.d.ts +19 -0
  106. package/dist/feature-assembly/as-of/refusal.d.ts.map +1 -0
  107. package/dist/feature-assembly/as-of/refusal.js +13 -0
  108. package/dist/feature-assembly/as-of/refusal.js.map +1 -0
  109. package/dist/feature-assembly/as-of/series-features.d.ts +65 -0
  110. package/dist/feature-assembly/as-of/series-features.d.ts.map +1 -0
  111. package/dist/feature-assembly/as-of/series-features.js +97 -0
  112. package/dist/feature-assembly/as-of/series-features.js.map +1 -0
  113. package/dist/feature-assembly/as-of/windowed-aggregate.d.ts +36 -0
  114. package/dist/feature-assembly/as-of/windowed-aggregate.d.ts.map +1 -0
  115. package/dist/feature-assembly/as-of/windowed-aggregate.js +99 -0
  116. package/dist/feature-assembly/as-of/windowed-aggregate.js.map +1 -0
  117. package/dist/feature-assembly/as-of.d.ts +1 -9
  118. package/dist/feature-assembly/as-of.d.ts.map +1 -1
  119. package/dist/feature-assembly/as-of.js +2 -19
  120. package/dist/feature-assembly/as-of.js.map +1 -1
  121. package/dist/feature-assembly/assembly-metadata.d.ts +34 -0
  122. package/dist/feature-assembly/assembly-metadata.d.ts.map +1 -0
  123. package/dist/feature-assembly/assembly-metadata.js +26 -0
  124. package/dist/feature-assembly/assembly-metadata.js.map +1 -0
  125. package/dist/feature-assembly/data-access.d.ts +21 -2
  126. package/dist/feature-assembly/data-access.d.ts.map +1 -1
  127. package/dist/feature-assembly/data-access.js +14 -0
  128. package/dist/feature-assembly/data-access.js.map +1 -1
  129. package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -1
  130. package/dist/feature-assembly/feature-assembly-executor.js +5 -2
  131. package/dist/feature-assembly/feature-assembly-executor.js.map +1 -1
  132. package/dist/feature-assembly/index.d.ts +3 -0
  133. package/dist/feature-assembly/index.d.ts.map +1 -1
  134. package/dist/feature-assembly/index.js +3 -0
  135. package/dist/feature-assembly/index.js.map +1 -1
  136. package/dist/feature-assembly/leakage-guard.d.ts +1 -1
  137. package/dist/feature-assembly/leakage-guard.js +1 -1
  138. package/dist/feature-assembly/read-policy.d.ts +27 -0
  139. package/dist/feature-assembly/read-policy.d.ts.map +1 -0
  140. package/dist/feature-assembly/read-policy.js +63 -0
  141. package/dist/feature-assembly/read-policy.js.map +1 -0
  142. package/dist/feature-pipelines/feature-pipeline-engine.d.ts.map +1 -1
  143. package/dist/feature-pipelines/feature-pipeline-engine.js +3 -1
  144. package/dist/feature-pipelines/feature-pipeline-engine.js.map +1 -1
  145. package/dist/index.d.ts +5 -2
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +16 -4
  148. package/dist/index.js.map +1 -1
  149. package/dist/maintenance/index.d.ts +1 -0
  150. package/dist/maintenance/index.d.ts.map +1 -1
  151. package/dist/maintenance/index.js +1 -0
  152. package/dist/maintenance/index.js.map +1 -1
  153. package/dist/maintenance/maintenance-engine.d.ts +16 -19
  154. package/dist/maintenance/maintenance-engine.d.ts.map +1 -1
  155. package/dist/maintenance/maintenance-engine.js +53 -53
  156. package/dist/maintenance/maintenance-engine.js.map +1 -1
  157. package/dist/maintenance/metrics.d.ts +19 -15
  158. package/dist/maintenance/metrics.d.ts.map +1 -1
  159. package/dist/maintenance/metrics.js +29 -24
  160. package/dist/maintenance/metrics.js.map +1 -1
  161. package/dist/maintenance/psi-drift-detector.d.ts +246 -0
  162. package/dist/maintenance/psi-drift-detector.d.ts.map +1 -0
  163. package/dist/maintenance/psi-drift-detector.js +1002 -0
  164. package/dist/maintenance/psi-drift-detector.js.map +1 -0
  165. package/dist/maintenance/types.d.ts +11 -2
  166. package/dist/maintenance/types.d.ts.map +1 -1
  167. package/dist/maintenance/types.js.map +1 -1
  168. package/dist/migration/index.d.ts +8 -0
  169. package/dist/migration/index.d.ts.map +1 -0
  170. package/dist/migration/index.js +8 -0
  171. package/dist/migration/index.js.map +1 -0
  172. package/dist/migration/legacy-pipeline-migration.d.ts +138 -0
  173. package/dist/migration/legacy-pipeline-migration.d.ts.map +1 -0
  174. package/dist/migration/legacy-pipeline-migration.js +273 -0
  175. package/dist/migration/legacy-pipeline-migration.js.map +1 -0
  176. package/dist/operations/delegation.d.ts +58 -46
  177. package/dist/operations/delegation.d.ts.map +1 -1
  178. package/dist/operations/delegation.js +90 -77
  179. package/dist/operations/delegation.js.map +1 -1
  180. package/dist/operations/promote-model.operation.d.ts +2 -2
  181. package/dist/operations/promote-model.operation.d.ts.map +1 -1
  182. package/dist/operations/promote-model.operation.js +6 -2
  183. package/dist/operations/promote-model.operation.js.map +1 -1
  184. package/dist/operations/refusals.d.ts +5 -0
  185. package/dist/operations/refusals.d.ts.map +1 -1
  186. package/dist/operations/refusals.js +26 -1
  187. package/dist/operations/refusals.js.map +1 -1
  188. package/dist/operations/start-experiment-session.operation.js +3 -3
  189. package/dist/operations/train-model.mapping.d.ts +91 -0
  190. package/dist/operations/train-model.mapping.d.ts.map +1 -0
  191. package/dist/operations/train-model.mapping.js +145 -0
  192. package/dist/operations/train-model.mapping.js.map +1 -0
  193. package/dist/operations/train-model.operation.d.ts +14 -9
  194. package/dist/operations/train-model.operation.d.ts.map +1 -1
  195. package/dist/operations/train-model.operation.js +30 -51
  196. package/dist/operations/train-model.operation.js.map +1 -1
  197. package/dist/prediction-unit/decision-date-advance.d.ts +46 -0
  198. package/dist/prediction-unit/decision-date-advance.d.ts.map +1 -0
  199. package/dist/prediction-unit/decision-date-advance.js +79 -0
  200. package/dist/prediction-unit/decision-date-advance.js.map +1 -0
  201. package/dist/prediction-unit/index.d.ts +12 -0
  202. package/dist/prediction-unit/index.d.ts.map +1 -0
  203. package/dist/prediction-unit/index.js +12 -0
  204. package/dist/prediction-unit/index.js.map +1 -0
  205. package/dist/prediction-unit/target-validation.d.ts +21 -0
  206. package/dist/prediction-unit/target-validation.d.ts.map +1 -0
  207. package/dist/prediction-unit/target-validation.js +54 -0
  208. package/dist/prediction-unit/target-validation.js.map +1 -0
  209. package/dist/prediction-unit/unit-row-reader.d.ts +108 -0
  210. package/dist/prediction-unit/unit-row-reader.d.ts.map +1 -0
  211. package/dist/prediction-unit/unit-row-reader.js +348 -0
  212. package/dist/prediction-unit/unit-row-reader.js.map +1 -0
  213. package/dist/prediction-unit/unit-store.d.ts +28 -0
  214. package/dist/prediction-unit/unit-store.d.ts.map +1 -0
  215. package/dist/prediction-unit/unit-store.js +41 -0
  216. package/dist/prediction-unit/unit-store.js.map +1 -0
  217. package/dist/prediction-unit/unit-versioning.d.ts +43 -0
  218. package/dist/prediction-unit/unit-versioning.d.ts.map +1 -0
  219. package/dist/prediction-unit/unit-versioning.js +71 -0
  220. package/dist/prediction-unit/unit-versioning.js.map +1 -0
  221. package/dist/protocol/index.d.ts +9 -0
  222. package/dist/protocol/index.d.ts.map +1 -0
  223. package/dist/protocol/index.js +9 -0
  224. package/dist/protocol/index.js.map +1 -0
  225. package/dist/protocol/protocol-defaults.d.ts +37 -0
  226. package/dist/protocol/protocol-defaults.d.ts.map +1 -0
  227. package/dist/protocol/protocol-defaults.js +59 -0
  228. package/dist/protocol/protocol-defaults.js.map +1 -0
  229. package/dist/protocol/protocol-versioning.d.ts +46 -0
  230. package/dist/protocol/protocol-versioning.d.ts.map +1 -0
  231. package/dist/protocol/protocol-versioning.js +48 -0
  232. package/dist/protocol/protocol-versioning.js.map +1 -0
  233. package/dist/protocol/search-guard.d.ts +45 -0
  234. package/dist/protocol/search-guard.d.ts.map +1 -0
  235. package/dist/protocol/search-guard.js +50 -0
  236. package/dist/protocol/search-guard.js.map +1 -0
  237. package/dist/scoring/artifact-loader.d.ts +5 -32
  238. package/dist/scoring/artifact-loader.d.ts.map +1 -1
  239. package/dist/scoring/artifact-loader.js +4 -59
  240. package/dist/scoring/artifact-loader.js.map +1 -1
  241. package/dist/scoring/auto-train.d.ts +25 -5
  242. package/dist/scoring/auto-train.d.ts.map +1 -1
  243. package/dist/scoring/auto-train.js +48 -31
  244. package/dist/scoring/auto-train.js.map +1 -1
  245. package/dist/scoring/index.d.ts +3 -0
  246. package/dist/scoring/index.d.ts.map +1 -1
  247. package/dist/scoring/index.js +3 -0
  248. package/dist/scoring/index.js.map +1 -1
  249. package/dist/scoring/ml-model-inference-processor.d.ts +137 -10
  250. package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -1
  251. package/dist/scoring/ml-model-inference-processor.js +383 -40
  252. package/dist/scoring/ml-model-inference-processor.js.map +1 -1
  253. package/dist/scoring/model-readiness.d.ts +45 -0
  254. package/dist/scoring/model-readiness.d.ts.map +1 -1
  255. package/dist/scoring/model-readiness.js +49 -0
  256. package/dist/scoring/model-readiness.js.map +1 -1
  257. package/dist/scoring/register.d.ts +8 -3
  258. package/dist/scoring/register.d.ts.map +1 -1
  259. package/dist/scoring/register.js +28 -4
  260. package/dist/scoring/register.js.map +1 -1
  261. package/dist/scoring/seams.d.ts +18 -2
  262. package/dist/scoring/seams.d.ts.map +1 -1
  263. package/dist/scoring/seams.js +35 -10
  264. package/dist/scoring/seams.js.map +1 -1
  265. package/dist/scoring/shadow-scoring.d.ts +245 -0
  266. package/dist/scoring/shadow-scoring.d.ts.map +1 -0
  267. package/dist/scoring/shadow-scoring.js +510 -0
  268. package/dist/scoring/shadow-scoring.js.map +1 -0
  269. package/dist/scoring/startup-register.d.ts +3 -3
  270. package/dist/scoring/startup-register.d.ts.map +1 -1
  271. package/dist/scoring/startup-register.js +10 -4
  272. package/dist/scoring/startup-register.js.map +1 -1
  273. package/dist/scoring/storage-provider-artifact-loader.d.ts +14 -0
  274. package/dist/scoring/storage-provider-artifact-loader.d.ts.map +1 -0
  275. package/dist/scoring/storage-provider-artifact-loader.js +47 -0
  276. package/dist/scoring/storage-provider-artifact-loader.js.map +1 -0
  277. package/dist/scoring/training-keys.d.ts +27 -0
  278. package/dist/scoring/training-keys.d.ts.map +1 -0
  279. package/dist/scoring/training-keys.js +54 -0
  280. package/dist/scoring/training-keys.js.map +1 -0
  281. package/dist/scoring/types.d.ts +72 -7
  282. package/dist/scoring/types.d.ts.map +1 -1
  283. package/dist/scoring/types.js +4 -0
  284. package/dist/scoring/types.js.map +1 -1
  285. package/dist/sidecar-provider.d.ts +2 -2
  286. package/dist/sidecar-provider.js +3 -3
  287. package/dist/snapshot/code-version.d.ts +16 -0
  288. package/dist/snapshot/code-version.d.ts.map +1 -0
  289. package/dist/snapshot/code-version.js +39 -0
  290. package/dist/snapshot/code-version.js.map +1 -0
  291. package/dist/snapshot/holdout-carver.d.ts +110 -0
  292. package/dist/snapshot/holdout-carver.d.ts.map +1 -0
  293. package/dist/snapshot/holdout-carver.js +171 -0
  294. package/dist/snapshot/holdout-carver.js.map +1 -0
  295. package/dist/snapshot/index.d.ts +17 -0
  296. package/dist/snapshot/index.d.ts.map +1 -0
  297. package/dist/snapshot/index.js +17 -0
  298. package/dist/snapshot/index.js.map +1 -0
  299. package/dist/snapshot/snapshot-builder.d.ts +152 -0
  300. package/dist/snapshot/snapshot-builder.d.ts.map +1 -0
  301. package/dist/snapshot/snapshot-builder.js +286 -0
  302. package/dist/snapshot/snapshot-builder.js.map +1 -0
  303. package/dist/snapshot/snapshot-file-store.d.ts +161 -0
  304. package/dist/snapshot/snapshot-file-store.d.ts.map +1 -0
  305. package/dist/snapshot/snapshot-file-store.js +204 -0
  306. package/dist/snapshot/snapshot-file-store.js.map +1 -0
  307. package/dist/snapshot/snapshot-hash.d.ts +6 -0
  308. package/dist/snapshot/snapshot-hash.d.ts.map +1 -0
  309. package/dist/snapshot/snapshot-hash.js +16 -0
  310. package/dist/snapshot/snapshot-hash.js.map +1 -0
  311. package/dist/snapshot/snapshot-manifest.d.ts +43 -0
  312. package/dist/snapshot/snapshot-manifest.d.ts.map +1 -0
  313. package/dist/snapshot/snapshot-manifest.js +43 -0
  314. package/dist/snapshot/snapshot-manifest.js.map +1 -0
  315. package/dist/snapshot/snapshot-retrainer.d.ts +107 -0
  316. package/dist/snapshot/snapshot-retrainer.d.ts.map +1 -0
  317. package/dist/snapshot/snapshot-retrainer.js +194 -0
  318. package/dist/snapshot/snapshot-retrainer.js.map +1 -0
  319. package/dist/snapshot/snapshot-serialization.d.ts +99 -0
  320. package/dist/snapshot/snapshot-serialization.d.ts.map +1 -0
  321. package/dist/snapshot/snapshot-serialization.js +191 -0
  322. package/dist/snapshot/snapshot-serialization.js.map +1 -0
  323. package/dist/snapshot/training-snapshot-store.d.ts +38 -0
  324. package/dist/snapshot/training-snapshot-store.d.ts.map +1 -0
  325. package/dist/snapshot/training-snapshot-store.js +41 -0
  326. package/dist/snapshot/training-snapshot-store.js.map +1 -0
  327. package/dist/storage/ps-storage-provider.d.ts +108 -0
  328. package/dist/storage/ps-storage-provider.d.ts.map +1 -0
  329. package/dist/storage/ps-storage-provider.js +154 -0
  330. package/dist/storage/ps-storage-provider.js.map +1 -0
  331. package/dist/training/artifact-store.d.ts +12 -103
  332. package/dist/training/artifact-store.d.ts.map +1 -1
  333. package/dist/training/artifact-store.js +13 -137
  334. package/dist/training/artifact-store.js.map +1 -1
  335. package/dist/training/compute-cost.d.ts +23 -0
  336. package/dist/training/compute-cost.d.ts.map +1 -0
  337. package/dist/training/compute-cost.js +36 -0
  338. package/dist/training/compute-cost.js.map +1 -0
  339. package/dist/training/evaluation-protocol-store.d.ts +53 -0
  340. package/dist/training/evaluation-protocol-store.d.ts.map +1 -0
  341. package/dist/training/evaluation-protocol-store.js +54 -0
  342. package/dist/training/evaluation-protocol-store.js.map +1 -0
  343. package/dist/training/index.d.ts +9 -1
  344. package/dist/training/index.d.ts.map +1 -1
  345. package/dist/training/index.js +9 -1
  346. package/dist/training/index.js.map +1 -1
  347. package/dist/training/locked-holdout.d.ts +19 -4
  348. package/dist/training/locked-holdout.d.ts.map +1 -1
  349. package/dist/training/locked-holdout.js +29 -5
  350. package/dist/training/locked-holdout.js.map +1 -1
  351. package/dist/training/seams.d.ts +34 -8
  352. package/dist/training/seams.d.ts.map +1 -1
  353. package/dist/training/seams.js +74 -18
  354. package/dist/training/seams.js.map +1 -1
  355. package/dist/training/storage-provider-artifact-store.d.ts +49 -0
  356. package/dist/training/storage-provider-artifact-store.d.ts.map +1 -0
  357. package/dist/training/storage-provider-artifact-store.js +147 -0
  358. package/dist/training/storage-provider-artifact-store.js.map +1 -0
  359. package/dist/training/trainer-model-lineage.d.ts +32 -0
  360. package/dist/training/trainer-model-lineage.d.ts.map +1 -0
  361. package/dist/training/trainer-model-lineage.js +62 -0
  362. package/dist/training/trainer-model-lineage.js.map +1 -0
  363. package/dist/training/trainer-request.d.ts +50 -0
  364. package/dist/training/trainer-request.d.ts.map +1 -0
  365. package/dist/training/trainer-request.js +65 -0
  366. package/dist/training/trainer-request.js.map +1 -0
  367. package/dist/training/trainer-result.d.ts +30 -0
  368. package/dist/training/trainer-result.d.ts.map +1 -0
  369. package/dist/training/trainer-result.js +40 -0
  370. package/dist/training/trainer-result.js.map +1 -0
  371. package/dist/training/training-engine.d.ts +417 -64
  372. package/dist/training/training-engine.d.ts.map +1 -1
  373. package/dist/training/training-engine.js +869 -178
  374. package/dist/training/training-engine.js.map +1 -1
  375. package/dist/training/training-refusal.d.ts +15 -0
  376. package/dist/training/training-refusal.d.ts.map +1 -0
  377. package/dist/training/training-refusal.js +62 -0
  378. package/dist/training/training-refusal.js.map +1 -0
  379. package/dist/training/types.d.ts +133 -41
  380. package/dist/training/types.d.ts.map +1 -1
  381. package/dist/training/types.js +4 -4
  382. package/dist/training/unit-model-lineage.d.ts +72 -0
  383. package/dist/training/unit-model-lineage.d.ts.map +1 -0
  384. package/dist/training/unit-model-lineage.js +288 -0
  385. package/dist/training/unit-model-lineage.js.map +1 -0
  386. package/package.json +16 -13
  387. package/dist/operations/__tests__/helpers.d.ts +0 -30
  388. package/dist/operations/__tests__/helpers.d.ts.map +0 -1
  389. package/dist/operations/__tests__/helpers.js +0 -44
  390. package/dist/operations/__tests__/helpers.js.map +0 -1
@@ -22,7 +22,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
22
22
  import { RegisterClass } from '@memberjunction/global';
23
23
  import { BaseRemotableOperation } from '@memberjunction/core';
24
24
  import { PredictiveStudioStartExperimentSessionOperation, } from '@memberjunction/core-entities';
25
- import { ExperimentSessions, validateModelingPlanSpec, validateBudget, } from '@memberjunction/predictive-studio-core';
25
+ import { ExperimentSessions, ValidateModelingPlanSpec, ValidateBudget, } from '@memberjunction/predictive-studio-core';
26
26
  import { RunExperimentSessionViaOrchestrator } from './delegation.js';
27
27
  import { ExperimentSessionsUnavailableError } from '../actions/run-experiment.deps.js';
28
28
  import { PredictiveStudioRefusals } from './refusals.js';
@@ -80,7 +80,7 @@ let PredictiveStudioStartExperimentSessionServerOperation = class PredictiveStud
80
80
  if (!rawPlan) {
81
81
  throw new Error('planSpec is required (the approved modeling plan to execute)');
82
82
  }
83
- const validation = validateModelingPlanSpec(rawPlan);
83
+ const validation = ValidateModelingPlanSpec(rawPlan);
84
84
  if (!validation.ok) {
85
85
  const error = validation.error ?? 'unknown validation error';
86
86
  throw new Error(`planSpec is not a valid modeling plan: ${error}`);
@@ -119,7 +119,7 @@ let PredictiveStudioStartExperimentSessionServerOperation = class PredictiveStud
119
119
  if (!raw) {
120
120
  return undefined;
121
121
  }
122
- const validation = validateBudget(raw);
122
+ const validation = ValidateBudget(raw);
123
123
  return validation.ok ? validation.value : undefined;
124
124
  }
125
125
  };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @module operations/train-model.mapping
3
+ *
4
+ * What the Train surfaces (the `PredictiveStudio.TrainModel` operation and the Train ML Model action) accept and
5
+ * return. Both refuse the retired inputs with the same refusal, gather the same run facts once, and map them to the
6
+ * same output, so the two surfaces cannot drift apart.
7
+ *
8
+ * The output is read from the run's stored envelope: the gate decision and its reason, the trainer's holdout scores,
9
+ * the Training Snapshot and the Evaluation Protocol version. A run whose envelope cannot be read fails closed (it
10
+ * throws) rather than reporting a guessed status.
11
+ */
12
+ import type { MJMLModelEntity, PredictiveStudioTrainModelOutput, RetiredTrainModelInputs } from '@memberjunction/core-entities';
13
+ import { type PipelineRefusal } from '@memberjunction/predictive-studio-core';
14
+ import type { TrainModelResult } from '../training/types.js';
15
+ import { TrainingRefusedError } from '../training/training-refusal.js';
16
+ import type { IEvaluationProtocolStore } from '../training/evaluation-protocol-store.js';
17
+ /** The refusal that names an input a Train call may not send. */
18
+ type InputNotAcceptedRefusal = Extract<PipelineRefusal, {
19
+ kind: 'input-not-accepted';
20
+ }>;
21
+ /** A retired Train input: a key of the retired-input type that the `input-not-accepted` refusal can name. */
22
+ export type RetiredTrainInput = keyof RetiredTrainModelInputs & InputNotAcceptedRefusal['input'];
23
+ /** The retired Train inputs, in the order a refusal names them. */
24
+ export declare const RETIRED_TRAIN_INPUTS: readonly RetiredTrainInput[];
25
+ /** The status a run reports when the gate decision ships no model row. */
26
+ export type NoModelStatus = 'NoSignal' | 'KeptExistingRule';
27
+ /** The produced model row's fields the output reads. */
28
+ export type TrainedModelFacts = Pick<MJMLModelEntity, 'ID' | 'Version' | 'Status' | 'HoldoutMetrics'>;
29
+ /** Everything the Train output is built from, gathered once from the engine result and the protocol row. */
30
+ export interface TrainRunFacts {
31
+ /** The produced model row, or null when the gate decision ships no model. */
32
+ readonly Model: TrainedModelFacts | null;
33
+ /** One feature dominates the finalist's predictions (the run's LEAKAGE WARNING note). */
34
+ readonly LeakageFlagged: boolean;
35
+ readonly RunID: string;
36
+ readonly TrainingSnapshotID: string | null;
37
+ readonly EvaluationProtocolID: string | null;
38
+ /** `MJ: ML Evaluation Protocols.Version` of `EvaluationProtocolID`, read through the FK. */
39
+ readonly EvaluationProtocolVersion: number | null;
40
+ readonly ValidationResults: string | null;
41
+ }
42
+ type TrainOutput = PredictiveStudioTrainModelOutput;
43
+ /** The Train surfaces' input refusal, run facts and output mapping. */
44
+ export declare class TrainModelMapping {
45
+ /** The retired inputs present in a payload, by own-property presence: a key sent with an empty value is still sent. */
46
+ static PresentRetiredInputs(payload: object): RetiredTrainInput[];
47
+ /** The sentence that names every retired input a call sent. */
48
+ static RetiredInputsMessage(surface: string, names: readonly string[]): string;
49
+ /**
50
+ * The refusal for a call that sent retired inputs (the first one is the refusal's `input`, the message names them
51
+ * all), or null when it sent none. `shownAs` is how the surface names them (an action's param names).
52
+ */
53
+ static RetiredInputRefusal(surface: string, present: readonly RetiredTrainInput[], shownAs?: readonly string[]): TrainingRefusedError | null;
54
+ /**
55
+ * The run facts both surfaces map: the model row, the dominance flag, the run's references and the protocol version
56
+ * read through the run's `EvaluationProtocolID`.
57
+ *
58
+ * @throws Error when the run names a protocol row that cannot be read
59
+ */
60
+ static GatherRunFacts(result: TrainModelResult, protocols: IEvaluationProtocolStore): Promise<TrainRunFacts>;
61
+ /**
62
+ * The Train output: the model fields when a model was produced, the stored gate decision and its reason, the holdout
63
+ * scores, and the snapshot and protocol the run used.
64
+ *
65
+ * @throws Error when the stored envelope cannot be read, or the run produced no model and its decision does not say why
66
+ */
67
+ static TrainModelOutputFrom(f: TrainRunFacts): TrainOutput;
68
+ /**
69
+ * The one sentence a finished Train call reports: the produced model and its version, or the stored reason no model
70
+ * shipped. Read from the mapped output, so both surfaces report the reason the output carries.
71
+ */
72
+ static FinishedMessage(out: TrainOutput): string;
73
+ /** The protocol row's Version, or null for a run with no protocol; a protocol the run names but nobody can read throws. */
74
+ private static protocolVersionOf;
75
+ /** The completed envelope; any other stored value fails closed. */
76
+ private static completedResults;
77
+ /** The model's status, or the status the stored decision names when no model was produced. */
78
+ private static statusOf;
79
+ /** No-signal, or the unit's existing rule kept; null for a decision that should have produced a model. */
80
+ private static noModelStatus;
81
+ private static modelFields;
82
+ /**
83
+ * The produced model's stored scores (the member the gate ships) when a model exists, otherwise the trainer's
84
+ * finalist scores. A model row with empty scores reports none, never another member's.
85
+ */
86
+ private static holdoutField;
87
+ private static referenceFields;
88
+ private static gateFields;
89
+ }
90
+ export {};
91
+ //# sourceMappingURL=train-model.mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-model.mapping.d.ts","sourceRoot":"","sources":["../../src/operations/train-model.mapping.ts"],"names":[],"mappings":"AAAA;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AAC;IAClD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAGD,KAAK,WAAW,GAAG,gCAAgC,CAAC;AAEpD,uEAAuE;AACvE,qBAAa,iBAAiB;IAC5B,uHAAuH;WACzG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAIxE,+DAA+D;WACjD,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAIrF;;;OAGG;WACW,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,OAAO,GAAE,SAAS,MAAM,EAAY,GAAG,oBAAoB,GAAG,IAAI;IAQ5J;;;;;OAKG;WACiB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAczH;;;;;OAKG;WACW,oBAAoB,CAAC,CAAC,EAAE,aAAa,GAAG,WAAW;IAajE;;;OAGG;WACW,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM;IAOvD,2HAA2H;mBACtG,iBAAiB;IAOtC,mEAAmE;IACnE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAO/B,8FAA8F;IAC9F,OAAO,CAAC,MAAM,CAAC,QAAQ;IAQvB,0GAA0G;IAC1G,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,eAAe;IAQ9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAK1B"}
@@ -0,0 +1,145 @@
1
+ import { GateRules, TrainingRunResultsParser, } from '@memberjunction/predictive-studio-core';
2
+ import { TrainingRefusedError } from '../training/training-refusal.js';
3
+ import { WasTrainingLeakageFlagged } from './delegation.js';
4
+ /** The retired Train inputs, in the order a refusal names them. */
5
+ export const RETIRED_TRAIN_INPUTS = ['asOf', 'labelEventDates', 'maxRows', 'primaryKeyField'];
6
+ /** Compile-time completeness: a key added to `RetiredTrainModelInputs` without listing it here breaks the build. */
7
+ const retiredInputsComplete = true;
8
+ void retiredInputsComplete;
9
+ /** The Train surfaces' input refusal, run facts and output mapping. */
10
+ export class TrainModelMapping {
11
+ /** The retired inputs present in a payload, by own-property presence: a key sent with an empty value is still sent. */
12
+ static PresentRetiredInputs(payload) {
13
+ return RETIRED_TRAIN_INPUTS.filter((k) => Object.prototype.hasOwnProperty.call(payload, k));
14
+ }
15
+ /** The sentence that names every retired input a call sent. */
16
+ static RetiredInputsMessage(surface, names) {
17
+ return `${surface} no longer accepts ${names.join(', ')}: the Prediction Unit declares the decision date and the row key, and every eligible row is read. Remove them from the call.`;
18
+ }
19
+ /**
20
+ * The refusal for a call that sent retired inputs (the first one is the refusal's `input`, the message names them
21
+ * all), or null when it sent none. `shownAs` is how the surface names them (an action's param names).
22
+ */
23
+ static RetiredInputRefusal(surface, present, shownAs = present) {
24
+ if (present.length === 0)
25
+ return null;
26
+ return new TrainingRefusedError({
27
+ stage: 'pipeline',
28
+ reason: { kind: 'input-not-accepted', input: present[0], why: TrainModelMapping.RetiredInputsMessage(surface, shownAs) },
29
+ });
30
+ }
31
+ /**
32
+ * The run facts both surfaces map: the model row, the dominance flag, the run's references and the protocol version
33
+ * read through the run's `EvaluationProtocolID`.
34
+ *
35
+ * @throws Error when the run names a protocol row that cannot be read
36
+ */
37
+ static async GatherRunFacts(result, protocols) {
38
+ const run = result.run;
39
+ const model = result.model;
40
+ return {
41
+ Model: model === null ? null : { ID: model.ID, Version: model.Version, Status: model.Status, HoldoutMetrics: model.HoldoutMetrics },
42
+ LeakageFlagged: WasTrainingLeakageFlagged(result),
43
+ RunID: run.ID,
44
+ TrainingSnapshotID: run.TrainingSnapshotID,
45
+ EvaluationProtocolID: run.EvaluationProtocolID,
46
+ EvaluationProtocolVersion: await TrainModelMapping.protocolVersionOf(run.ID, run.EvaluationProtocolID, protocols),
47
+ ValidationResults: run.ValidationResults,
48
+ };
49
+ }
50
+ /**
51
+ * The Train output: the model fields when a model was produced, the stored gate decision and its reason, the holdout
52
+ * scores, and the snapshot and protocol the run used.
53
+ *
54
+ * @throws Error when the stored envelope cannot be read, or the run produced no model and its decision does not say why
55
+ */
56
+ static TrainModelOutputFrom(f) {
57
+ const completed = TrainModelMapping.completedResults(f);
58
+ return {
59
+ ...TrainModelMapping.modelFields(f.Model),
60
+ trainingRunId: f.RunID,
61
+ status: TrainModelMapping.statusOf(f, completed.gate),
62
+ leakageFlagged: f.LeakageFlagged,
63
+ ...TrainModelMapping.holdoutField(f.Model, completed.trainer),
64
+ ...TrainModelMapping.referenceFields(f),
65
+ ...TrainModelMapping.gateFields(completed.gate),
66
+ };
67
+ }
68
+ /**
69
+ * The one sentence a finished Train call reports: the produced model and its version, or the stored reason no model
70
+ * shipped. Read from the mapped output, so both surfaces report the reason the output carries.
71
+ */
72
+ static FinishedMessage(out) {
73
+ // `||`: the mapping stores a gate whenever no model ships; an absent reason still names the status, never "undefined".
74
+ return out.modelId
75
+ ? `Trained model ${out.modelId} (v${out.version}).`
76
+ : `Training run ${out.trainingRunId} completed and shipped no model: ${out.gateReason || out.status}`;
77
+ }
78
+ /** The protocol row's Version, or null for a run with no protocol; a protocol the run names but nobody can read throws. */
79
+ static async protocolVersionOf(runId, protocolId, protocols) {
80
+ if (protocolId === null)
81
+ return null;
82
+ const row = await protocols.Load(protocolId);
83
+ if (row === null)
84
+ throw new Error(`training run ${runId} names Evaluation Protocol '${protocolId}', which cannot be read`);
85
+ return row.Version;
86
+ }
87
+ /** The completed envelope; any other stored value fails closed. */
88
+ static completedResults(f) {
89
+ const parsed = TrainingRunResultsParser.ParseTrainingRunResults(f.ValidationResults);
90
+ if (parsed.Ok === false)
91
+ throw new Error(`training run ${f.RunID} stored results that cannot be read: ${parsed.Errors.join('; ')}`);
92
+ if (parsed.Value.status !== 'completed')
93
+ throw new Error(`training run ${f.RunID} stored a refusal, so its results cannot be read as a completed run`);
94
+ return parsed.Value;
95
+ }
96
+ /** The model's status, or the status the stored decision names when no model was produced. */
97
+ static statusOf(f, gate) {
98
+ if (f.Model !== null)
99
+ return f.Model.Status;
100
+ if (gate === null)
101
+ throw new Error(`training run ${f.RunID} produced no model and stored no gate decision`);
102
+ const status = TrainModelMapping.noModelStatus(gate);
103
+ if (status === null)
104
+ throw new Error(`training run ${f.RunID} stored the outcome ${gate.decision.outcome} shipping ${gate.decision.shipped} but produced no model`);
105
+ return status;
106
+ }
107
+ /** No-signal, or the unit's existing rule kept; null for a decision that should have produced a model. */
108
+ static noModelStatus(gate) {
109
+ if (gate.decision.outcome === 'no-signal')
110
+ return 'NoSignal';
111
+ return gate.decision.shipped.startsWith(GateRules.HeuristicPrefix) ? 'KeptExistingRule' : null;
112
+ }
113
+ static modelFields(model) {
114
+ return model === null ? {} : { modelId: model.ID, version: model.Version };
115
+ }
116
+ /**
117
+ * The produced model's stored scores (the member the gate ships) when a model exists, otherwise the trainer's
118
+ * finalist scores. A model row with empty scores reports none, never another member's.
119
+ */
120
+ static holdoutField(model, trainer) {
121
+ // `if (text)`: an empty HoldoutMetrics string is no scores, the same as null.
122
+ if (model !== null)
123
+ return model.HoldoutMetrics ? { holdoutMetrics: model.HoldoutMetrics } : {};
124
+ if (trainer === null)
125
+ return {};
126
+ const scores = { [trainer.holdout.primary.metric]: trainer.holdout.primary.value };
127
+ for (const m of trainer.holdout.secondary)
128
+ scores[m.metric] = m.value;
129
+ return { holdoutMetrics: JSON.stringify(scores) };
130
+ }
131
+ static referenceFields(f) {
132
+ return {
133
+ ...(f.TrainingSnapshotID === null ? {} : { trainingSnapshotId: f.TrainingSnapshotID }),
134
+ ...(f.EvaluationProtocolID === null ? {} : { evaluationProtocolId: f.EvaluationProtocolID }),
135
+ ...(f.EvaluationProtocolVersion === null ? {} : { evaluationProtocolVersion: f.EvaluationProtocolVersion }),
136
+ };
137
+ }
138
+ static gateFields(gate) {
139
+ if (gate === null)
140
+ return {};
141
+ const d = gate.decision;
142
+ return { gateOutcome: d.outcome, gateBranch: d.branch, gateReason: gate.reason.text, ...(d.shipped === null ? {} : { shipped: d.shipped }) };
143
+ }
144
+ }
145
+ //# sourceMappingURL=train-model.mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-model.mapping.js","sourceRoot":"","sources":["../../src/operations/train-model.mapping.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,SAAS,EAAE,wBAAwB,GAEpC,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAQzD,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAiC,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAI5H,oHAAoH;AACpH,MAAM,qBAAqB,GAA2F,IAAI,CAAC;AAC3H,KAAK,qBAAqB,CAAC;AAyB3B,uEAAuE;AACvE,MAAM,OAAO,iBAAiB;IAC5B,uHAAuH;IAChH,MAAM,CAAC,oBAAoB,CAAC,OAAe;QAChD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,+DAA+D;IACxD,MAAM,CAAC,oBAAoB,CAAC,OAAe,EAAE,KAAwB;QAC1E,OAAO,GAAG,OAAO,sBAAsB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,8HAA8H,CAAC;IACxL,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,mBAAmB,CAAC,OAAe,EAAE,OAAqC,EAAE,UAA6B,OAAO;QAC5H,IAAI,OAAO,CAAC,MAAM,KAAK,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EAAE,CAAC,CAAC,yBAAyB,EAAE,CAAC;SAC5G,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,IAA6B;QACrD,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QACxB,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IAC/I,CAAC;CACF"}
@@ -8,9 +8,10 @@
8
8
  * maps the typed input → `TrainingEngine.trainModel` → the typed output.
9
9
  *
10
10
  * Per CLAUDE.md "transport-layer architecture", the operation is a THIN adapter —
11
- * it carries no training logic. The actual orchestration (locked-holdout carve,
12
- * sidecar `/train`, immutable model persist, leakage flag) lives in the engine, and
13
- * the production wiring is shared with the Train action via {@link TrainModelViaEngine}.
11
+ * it carries no training logic. The engine trains the pipeline under its Prediction
12
+ * Unit and bound Evaluation Protocol and stores the gate decision on the run; the
13
+ * production wiring is shared with the Train action via {@link TrainingDelegation.TrainModelViaEngine},
14
+ * and the output is read from the run with {@link TrainModelMapping}, as the action reads it.
14
15
  *
15
16
  * Marked `LongRunning` (training can take a while): it emits coarse start/finish
16
17
  * progress through the server context. The engine does not expose a per-epoch
@@ -22,6 +23,7 @@ import { type RemoteOpServerContext } from '@memberjunction/core';
22
23
  import { PredictiveStudioTrainModelOperation, type PredictiveStudioTrainModelInput, type PredictiveStudioTrainModelOutput } from '@memberjunction/core-entities';
23
24
  import type { TrainModelInput } from '../training/types.js';
24
25
  import { TrainingEngine } from '../training/training-engine.js';
26
+ import { type IEvaluationProtocolStore } from '../training/evaluation-protocol-store.js';
25
27
  /**
26
28
  * Server implementation of `PredictiveStudio.TrainModel`. Extends the CodeGen-emitted
27
29
  * {@link PredictiveStudioTrainModelOperation} base (which carries the `OperationKey`,
@@ -31,21 +33,24 @@ import { TrainingEngine } from '../training/training-engine.js';
31
33
  export declare class PredictiveStudioTrainModelServerOperation extends PredictiveStudioTrainModelOperation {
32
34
  /** Returns refusals as typed `ResultCode`s (see `PredictiveStudioRefusals`). */
33
35
  ExecuteServer(input: PredictiveStudioTrainModelInput, context: RemoteOpServerContext): Promise<RemoteOpResult<PredictiveStudioTrainModelOutput>>;
34
- /** @inheritdoc */
36
+ /**
37
+ * Refuses a retired input by name, trains, then returns the run's stored decision. A retired input is refused
38
+ * before any progress is reported, so a refused call never starts a training run.
39
+ */
35
40
  protected InternalExecute(input: PredictiveStudioTrainModelInput, provider: IMetadataProvider, user: UserInfo, context: RemoteOpServerContext): Promise<PredictiveStudioTrainModelOutput>;
36
41
  /**
37
- * Map the operation's typed input onto the engine's {@link TrainModelInput}.
38
- * The shapes are nearly 1:1; `labelEventDates` is the only field that differs —
39
- * the wire shape carries ISO date strings, the engine wants `Date`s.
42
+ * Map the operation's typed input onto the engine's {@link TrainModelInput}. The retired inputs are refused before
43
+ * this runs (the type no longer carries them), so only the pipeline, the session iteration and the sidecar version map.
40
44
  */
41
45
  protected toEngineInput(input: PredictiveStudioTrainModelInput): TrainModelInput;
42
- /** Parse the wire's `{ recordKey: ISO-string }` label-event map into `Date`s. */
43
- protected parseLabelEventDates(map: Record<string, string>): Record<string, Date>;
44
46
  /**
45
47
  * The {@link TrainingEngine} instance to delegate to. Overridable so unit tests
46
48
  * inject a mock engine with no live DB / sidecar (mirrors the Action's seam).
47
49
  */
48
50
  protected engine(): TrainingEngine;
51
+ /** Where the run's protocol version is read, through the request's provider and user. Overridable for tests. */
52
+ protected protocolStore(provider: IMetadataProvider, user: UserInfo): IEvaluationProtocolStore;
53
+ private reportProgress;
49
54
  }
50
55
  /** Tree-shaking anchor — call from a server bootstrap to retain this registration. */
51
56
  export declare function LoadPredictiveStudioTrainModelOperation(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"train-model.operation.d.ts","sourceRoot":"","sources":["../../src/operations/train-model.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,mCAAmC,EACnC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACtC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D;;;;;GAKG;AACH,qBACa,yCAA0C,SAAQ,mCAAmC;IAChG,gFAAgF;IAC1D,aAAa,CACjC,KAAK,EAAE,+BAA+B,EACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,gCAAgC,CAAC,CAAC;IAQ5D,kBAAkB;cACF,eAAe,CAC7B,KAAK,EAAE,+BAA+B,EACtC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,gCAAgC,CAAC;IAmC5C;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,+BAA+B,GAAG,eAAe;IAoBhF,iFAAiF;IACjF,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IAQjF;;;OAGG;IACH,SAAS,CAAC,MAAM,IAAI,cAAc;CAGnC;AAED,sFAAsF;AACtF,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
1
+ {"version":3,"file":"train-model.operation.d.ts","sourceRoot":"","sources":["../../src/operations/train-model.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,mCAAmC,EACnC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACtC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAKtH;;;;;GAKG;AACH,qBACa,yCAA0C,SAAQ,mCAAmC;IAChG,gFAAgF;IAC1D,aAAa,CACjC,KAAK,EAAE,+BAA+B,EACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,gCAAgC,CAAC,CAAC;IAQ5D;;;OAGG;cACa,eAAe,CAC7B,KAAK,EAAE,+BAA+B,EACtC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,gCAAgC,CAAC;IAe5C;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,+BAA+B,GAAG,eAAe;IAWhF;;;OAGG;IACH,SAAS,CAAC,MAAM,IAAI,cAAc;IAIlC,gHAAgH;IAChH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,wBAAwB;IAI9F,OAAO,CAAC,cAAc;CAGvB;AAED,sFAAsF;AACtF,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
@@ -8,9 +8,10 @@
8
8
  * maps the typed input → `TrainingEngine.trainModel` → the typed output.
9
9
  *
10
10
  * Per CLAUDE.md "transport-layer architecture", the operation is a THIN adapter —
11
- * it carries no training logic. The actual orchestration (locked-holdout carve,
12
- * sidecar `/train`, immutable model persist, leakage flag) lives in the engine, and
13
- * the production wiring is shared with the Train action via {@link TrainModelViaEngine}.
11
+ * it carries no training logic. The engine trains the pipeline under its Prediction
12
+ * Unit and bound Evaluation Protocol and stores the gate decision on the run; the
13
+ * production wiring is shared with the Train action via {@link TrainingDelegation.TrainModelViaEngine},
14
+ * and the output is read from the run with {@link TrainModelMapping}, as the action reads it.
14
15
  *
15
16
  * Marked `LongRunning` (training can take a while): it emits coarse start/finish
16
17
  * progress through the server context. The engine does not expose a per-epoch
@@ -26,10 +27,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
26
27
  import { RegisterClass } from '@memberjunction/global';
27
28
  import { BaseRemotableOperation } from '@memberjunction/core';
28
29
  import { PredictiveStudioTrainModelOperation, } from '@memberjunction/core-entities';
29
- import { AsOfSettingHasNoEffectError } from '../training/as-of-refusal.js';
30
30
  import { TrainingEngine } from '../training/training-engine.js';
31
- import { TrainModelViaEngine, WasTrainingLeakageFlagged } from './delegation.js';
31
+ import { RunViewEvaluationProtocolStore } from '../training/evaluation-protocol-store.js';
32
+ import { TrainingDelegation } from './delegation.js';
32
33
  import { PredictiveStudioRefusals } from './refusals.js';
34
+ import { TrainModelMapping } from './train-model.mapping.js';
33
35
  /**
34
36
  * Server implementation of `PredictiveStudio.TrainModel`. Extends the CodeGen-emitted
35
37
  * {@link PredictiveStudioTrainModelOperation} base (which carries the `OperationKey`,
@@ -41,69 +43,39 @@ let PredictiveStudioTrainModelServerOperation = class PredictiveStudioTrainModel
41
43
  async ExecuteServer(input, context) {
42
44
  return PredictiveStudioRefusals.ExecuteServer(() => this.Authorize(input, context.user), () => this.InternalExecute(input, context.provider, context.user, context), this.OperationKey);
43
45
  }
44
- /** @inheritdoc */
46
+ /**
47
+ * Refuses a retired input by name, trains, then returns the run's stored decision. A retired input is refused
48
+ * before any progress is reported, so a refused call never starts a training run.
49
+ */
45
50
  async InternalExecute(input, provider, user, context) {
46
51
  if (!input?.pipelineId) {
47
52
  throw new Error('pipelineId is required');
48
53
  }
49
- if (AsOfSettingHasNoEffectError.WouldBeIgnored(input.asOf)) {
50
- throw new AsOfSettingHasNoEffectError('train-input', input.asOf.Mode, input.pipelineId);
51
- }
52
- context.emitProgress({
53
- OperationKey: this.OperationKey,
54
- Processed: 0,
55
- Status: 'Running',
56
- Message: `Training model from pipeline ${input.pipelineId}…`,
57
- });
58
- const result = await TrainModelViaEngine(this.toEngineInput(input), provider, user, this.engine());
59
- context.emitProgress({
60
- OperationKey: this.OperationKey,
61
- Processed: 1,
62
- Total: 1,
63
- Status: 'Running',
64
- Message: `Trained model ${result.model.ID} (v${result.model.Version}).`,
65
- });
66
- return {
67
- modelId: result.model.ID,
68
- trainingRunId: result.run.ID,
69
- version: result.model.Version,
70
- holdoutMetrics: result.model.HoldoutMetrics ?? undefined,
71
- leakageFlagged: WasTrainingLeakageFlagged(result),
72
- status: result.model.Status,
73
- };
54
+ const retired = TrainModelMapping.RetiredInputRefusal('TrainModel', TrainModelMapping.PresentRetiredInputs(input));
55
+ if (retired !== null)
56
+ throw retired;
57
+ const engineInput = this.toEngineInput(input);
58
+ this.reportProgress(context, 0, `Training model from pipeline ${input.pipelineId}…`);
59
+ const result = await TrainingDelegation.TrainModelViaEngine(engineInput, provider, user, this.engine());
60
+ // The output is mapped (and may fail closed) before the finishing line, so "completed" is never followed by an error.
61
+ const out = TrainModelMapping.TrainModelOutputFrom(await TrainModelMapping.GatherRunFacts(result, this.protocolStore(provider, user)));
62
+ this.reportProgress(context, 1, TrainModelMapping.FinishedMessage(out));
63
+ return out;
74
64
  }
75
65
  /**
76
- * Map the operation's typed input onto the engine's {@link TrainModelInput}.
77
- * The shapes are nearly 1:1; `labelEventDates` is the only field that differs —
78
- * the wire shape carries ISO date strings, the engine wants `Date`s.
66
+ * Map the operation's typed input onto the engine's {@link TrainModelInput}. The retired inputs are refused before
67
+ * this runs (the type no longer carries them), so only the pipeline, the session iteration and the sidecar version map.
79
68
  */
80
69
  toEngineInput(input) {
81
70
  const engineInput = { pipelineId: input.pipelineId };
82
71
  if (input.experimentSessionIterationId) {
83
72
  engineInput.experimentSessionIterationId = input.experimentSessionIterationId;
84
73
  }
85
- if (input.maxRows != null) {
86
- engineInput.maxRows = input.maxRows;
87
- }
88
- if (input.primaryKeyField) {
89
- engineInput.primaryKeyField = input.primaryKeyField;
90
- }
91
74
  if (input.sidecarVersion) {
92
75
  engineInput.sidecarVersion = input.sidecarVersion;
93
76
  }
94
- if (input.labelEventDates) {
95
- engineInput.labelEventDates = this.parseLabelEventDates(input.labelEventDates);
96
- }
97
77
  return engineInput;
98
78
  }
99
- /** Parse the wire's `{ recordKey: ISO-string }` label-event map into `Date`s. */
100
- parseLabelEventDates(map) {
101
- const out = {};
102
- for (const [key, iso] of Object.entries(map)) {
103
- out[key] = new Date(iso);
104
- }
105
- return out;
106
- }
107
79
  /**
108
80
  * The {@link TrainingEngine} instance to delegate to. Overridable so unit tests
109
81
  * inject a mock engine with no live DB / sidecar (mirrors the Action's seam).
@@ -111,6 +83,13 @@ let PredictiveStudioTrainModelServerOperation = class PredictiveStudioTrainModel
111
83
  engine() {
112
84
  return new TrainingEngine();
113
85
  }
86
+ /** Where the run's protocol version is read, through the request's provider and user. Overridable for tests. */
87
+ protocolStore(provider, user) {
88
+ return new RunViewEvaluationProtocolStore(provider, user);
89
+ }
90
+ reportProgress(context, processed, message) {
91
+ context.emitProgress({ OperationKey: this.OperationKey, Processed: processed, ...(processed === 1 ? { Total: 1 } : {}), Status: 'Running', Message: message });
92
+ }
114
93
  };
115
94
  PredictiveStudioTrainModelServerOperation = __decorate([
116
95
  RegisterClass(BaseRemotableOperation, 'PredictiveStudio.TrainModel')
@@ -1 +1 @@
1
- {"version":3,"file":"train-model.operation.js","sourceRoot":"","sources":["../../src/operations/train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AI,IAAI,EAAE,CAAC;YAC1B,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QACtC,CAAC;QACD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,WAAW,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QACpD,CAAC;QACD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,iFAAiF;IACvE,oBAAoB,CAAC,GAA2B;QACxD,MAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;OAGG;IACO,MAAM;QACd,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;CACF,CAAA;AA/FY,yCAAyC;IADrD,aAAa,CAAC,sBAAsB,EAAE,6BAA6B,CAAC;GACxD,yCAAyC,CA+FrD;;AAED,sFAAsF;AACtF,MAAM,UAAU,uCAAuC;IACrD,sBAAsB;AACxB,CAAC"}
1
+ {"version":3,"file":"train-model.operation.js","sourceRoot":"","sources":["../../src/operations/train-model.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,s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,GAAG,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACjK,CAAC;CACF,CAAA;AApEY,yCAAyC;IADrD,aAAa,CAAC,sBAAsB,EAAE,6BAA6B,CAAC;GACxD,yCAAyC,CAoErD;;AAED,sFAAsF;AACtF,MAAM,UAAU,uCAAuC;IACrD,sBAAsB;AACxB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @module prediction-unit/decision-date-advance
3
+ *
4
+ * A fixed decision date with `advance: 'each-run'` (a migrated pipeline that had no as-of) moves to each run's UTC
5
+ * day: before the run, the engine saves the next unit version with that day and the censoring cutoff moved by the
6
+ * unit's label window, and points the pipeline at it. The model then references the exact version it was trained under.
7
+ */
8
+ import type { UserInfo } from '@memberjunction/core';
9
+ import type { MJMLTrainingPipelineEntity } from '@memberjunction/core-entities';
10
+ import { type Actor, type PredictionUnitSpec, type UnitDraft } from '@memberjunction/predictive-studio-core';
11
+ import type { IAssemblyMetadata } from '../feature-assembly/assembly-metadata.js';
12
+ import type { IEntityFactory } from '../training/types.js';
13
+ import { type IPredictionUnitStore } from './unit-store.js';
14
+ /** The author recorded on every unit version a decision-date advance saves. */
15
+ export declare const DECISION_DATE_ADVANCE_ACTOR: Actor;
16
+ /** What advancing a pipeline's unit needs: the unit store, the run's day, the metadata and the entity factory. */
17
+ export interface DecisionDateAdvanceDeps {
18
+ readonly Store: IPredictionUnitStore;
19
+ /** The run's UTC day, `yyyy-mm-dd`. */
20
+ readonly RunDay: string;
21
+ readonly Metadata: IAssemblyMetadata;
22
+ readonly EntityFactory: IEntityFactory;
23
+ readonly ContextUser?: UserInfo;
24
+ }
25
+ /** Advancing fixed decision dates. */
26
+ export declare class DecisionDateAdvance {
27
+ /**
28
+ * Whether the unit's decision date is fixed and advances to each run's UTC day. Training saves the advanced version
29
+ * before it reads; scoring reads such a unit's rows as of the scoring run's own day (the stored date is the day the
30
+ * model was trained).
31
+ */
32
+ static AdvancesEachRun(unit: PredictionUnitSpec): boolean;
33
+ /** Pure: the changes that move an advancing fixed decision date to `runDay`; null when the rule does not advance or is already there. */
34
+ static DecisionDateAdvanceChanges(unit: PredictionUnitSpec, runDay: string): Partial<UnitDraft> | null;
35
+ /**
36
+ * Advances the pipeline's bound unit when due and returns the unit ID to train under (null when the pipeline has
37
+ * none). Only the newest version of a lineage advances: a pipeline bound to an older version keeps it (that binding
38
+ * is deliberate). A missing or unparsable unit is left to the engine's own refusal. Everything after the new version
39
+ * is saved (parsing it, applying it to the pipeline, saving the pipeline) is one step: when any part fails, by a
40
+ * refusal or a throw, the new version is deleted and the pipeline's columns are put back, so nothing is orphaned.
41
+ */
42
+ static AdvanceFixedDecisionDate(pipeline: MJMLTrainingPipelineEntity, deps: DecisionDateAdvanceDeps): Promise<string | null>;
43
+ /** Points the pipeline at the new version and saves it: null when bound, else why not (a throw is reported, not raised). */
44
+ private static bindPipeline;
45
+ }
46
+ //# sourceMappingURL=decision-date-advance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-date-advance.d.ts","sourceRoot":"","sources":["../../src/prediction-unit/decision-date-advance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAA4B,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAA0B,KAAK,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACrI,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAA8B,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGrF,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,EAAE,KAA8D,CAAC;AAEzG,kHAAkH;AAClH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC;CACjC;AAED,sCAAsC;AACtC,qBAAa,mBAAmB;IAC9B;;;;OAIG;WACW,eAAe,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO;IAIhE,yIAAyI;WAC3H,0BAA0B,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;IAY7G;;;;;;OAMG;WACiB,wBAAwB,CAAC,QAAQ,EAAE,0BAA0B,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBzI,4HAA4H;mBACvG,YAAY;CAWlC"}
@@ -0,0 +1,79 @@
1
+ import { UUIDsEqual } from '@memberjunction/global';
2
+ import { PredictionUnit, UtcDay } from '@memberjunction/predictive-studio-core';
3
+ import { RunViewPredictionUnitStore } from './unit-store.js';
4
+ import { PredictionUnitVersioning } from './unit-versioning.js';
5
+ /** The author recorded on every unit version a decision-date advance saves. */
6
+ export const DECISION_DATE_ADVANCE_ACTOR = { kind: 'system', component: 'decision-date-advance' };
7
+ /** Advancing fixed decision dates. */
8
+ export class DecisionDateAdvance {
9
+ /**
10
+ * Whether the unit's decision date is fixed and advances to each run's UTC day. Training saves the advanced version
11
+ * before it reads; scoring reads such a unit's rows as of the scoring run's own day (the stored date is the day the
12
+ * model was trained).
13
+ */
14
+ static AdvancesEachRun(unit) {
15
+ return unit.rows.kind === 'grain' && unit.rows.decisionDate.kind === 'fixed' && unit.rows.decisionDate.advance === 'each-run';
16
+ }
17
+ /** Pure: the changes that move an advancing fixed decision date to `runDay`; null when the rule does not advance or is already there. */
18
+ static DecisionDateAdvanceChanges(unit, runDay) {
19
+ if (unit.rows.kind !== 'grain' || !DecisionDateAdvance.AdvancesEachRun(unit))
20
+ return null;
21
+ const rule = unit.rows.decisionDate;
22
+ if (rule.kind !== 'fixed' || rule.date === runDay)
23
+ return null;
24
+ const day = UtcDay.ToUtcDay(runDay);
25
+ if (day === null || !UtcDay.IsIsoDay(runDay))
26
+ throw new Error(`run day ${runDay} is not yyyy-mm-dd`);
27
+ return {
28
+ UnitRows: { ...unit.rows, decisionDate: { kind: 'fixed', date: runDay, advance: 'each-run' } },
29
+ Censoring: { rule: 'exclude-unresolved', cutoff: { kind: 'fixed', at: UtcDay.UtcDayIso(UtcDay.AddUtcDays(day, unit.label.windowDays + unit.label.gapDays)) } },
30
+ };
31
+ }
32
+ /**
33
+ * Advances the pipeline's bound unit when due and returns the unit ID to train under (null when the pipeline has
34
+ * none). Only the newest version of a lineage advances: a pipeline bound to an older version keeps it (that binding
35
+ * is deliberate). A missing or unparsable unit is left to the engine's own refusal. Everything after the new version
36
+ * is saved (parsing it, applying it to the pipeline, saving the pipeline) is one step: when any part fails, by a
37
+ * refusal or a throw, the new version is deleted and the pipeline's columns are put back, so nothing is orphaned.
38
+ */
39
+ static async AdvanceFixedDecisionDate(pipeline, deps) {
40
+ const unitId = pipeline.PredictionUnitID;
41
+ if (unitId === null)
42
+ return null;
43
+ const row = await deps.Store.Load(unitId);
44
+ const parsed = row === null ? null : PredictionUnit.ParsePredictionUnitRow(row);
45
+ if (row === null || parsed === null || parsed.Ok === false)
46
+ return unitId;
47
+ const changes = DecisionDateAdvance.DecisionDateAdvanceChanges(parsed.Value, deps.RunDay);
48
+ if (changes === null)
49
+ return unitId;
50
+ const latest = await deps.Store.LatestVersion(row.LineageRootID);
51
+ if (latest === null || !UUIDsEqual(latest.ID, row.ID))
52
+ return unitId;
53
+ const next = await PredictionUnitVersioning.CreateNextPredictionUnitVersion(row, changes, DECISION_DATE_ADVANCE_ACTOR, deps.EntityFactory, deps.ContextUser);
54
+ const prior = { PredictionUnitID: pipeline.PredictionUnitID, TargetEntityID: pipeline.TargetEntityID, TargetVariable: pipeline.TargetVariable, ProblemType: pipeline.ProblemType };
55
+ const why = await DecisionDateAdvance.bindPipeline(pipeline, next, deps.Metadata);
56
+ if (why === null)
57
+ return next.ID;
58
+ Object.assign(pipeline, prior);
59
+ if (await next.Delete())
60
+ throw new Error(why);
61
+ throw new Error(`${why}; deleting the unbound unit version ${next.ID} also failed: ${next.LatestResult?.CompleteMessage || 'delete failed'}`);
62
+ }
63
+ /** Points the pipeline at the new version and saves it: null when bound, else why not (a throw is reported, not raised). */
64
+ static async bindPipeline(pipeline, next, metadata) {
65
+ try {
66
+ const nextSpec = PredictionUnit.ParsePredictionUnitRow(next);
67
+ if (nextSpec.Ok === false)
68
+ return `Advanced unit ${next.ID} does not parse: ${nextSpec.Errors.join('; ')}`;
69
+ RunViewPredictionUnitStore.ApplyUnitToPipeline(pipeline, next.ID, nextSpec.Value, metadata);
70
+ if (await pipeline.Save())
71
+ return null;
72
+ return `Binding pipeline ${pipeline.ID} to unit ${next.ID} failed: ${pipeline.LatestResult?.CompleteMessage || 'save failed'}`;
73
+ }
74
+ catch (e) {
75
+ return `Binding pipeline ${pipeline.ID} to unit ${next.ID} failed: ${e instanceof Error ? e.message : String(e)}`;
76
+ }
77
+ }
78
+ }
79
+ //# sourceMappingURL=decision-date-advance.js.map