@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
@@ -5,183 +5,70 @@
5
5
  * of Database Designer's schema builder and Agent Manager's `AgentSpecSync`. It takes an approved,
6
6
  * strongly-typed {@link ModelingPlanSpec} and, in pure code (NO LLM), crafts the actual metadata:
7
7
  * creates the `MJ: ML Training Pipelines` row, kicks off training, then **publishes the model only
8
- * if the trust verdict clears the bar** — the same `TrustVerdicts.DeriveTrustVerdict` gate the business UI uses, so
9
- * a coin-flip / unmeasured / leakage-flagged model is never silently published into the catalog.
8
+ * if the trust verdict clears the bar** — the same `TrustVerdicts.DeriveTrustVerdict` rendering of the training run's
9
+ * stored gate decision the business UI uses, so a model the gate did not ship, a model trained without an Evaluation
10
+ * Protocol (not evaluated), a leakage-flagged model or a calibration-held model is never silently published into the
11
+ * catalog. Publishing goes through the promotion gate (`ProductionModelPromotionGate`: Draft → Validated → Published,
12
+ * with no sign-off), so its readiness checks and the per-model scoring Action apply; a refusal holds the model with
13
+ * the gate's reason.
14
+ *
15
+ * Every approved experiment is a candidate of ONE search on ONE pipeline. The saved pipeline is bound to version 1 of
16
+ * a Prediction Unit mapped from the plan's target (the pipeline migration's mapping; a target the mapping would archive
17
+ * or hold is refused) and to an Evaluation Protocol before it trains, and the trainer picks the finalist on inner-fold
18
+ * scores (the simplest candidate within one standard error of the best), reading the held-back rows once, for the
19
+ * finalist.
10
20
  *
11
21
  * Used by the agent's builder sub-agent AND directly callable from a headless script/test, so the
12
22
  * "build a new prediction" path is verifiable without the full LLM loop.
13
23
  */
14
- import { UUIDsEqual } from '@memberjunction/global';
15
- import { RunView, LogError } from '@memberjunction/core';
16
- import { TrustVerdicts } from '@memberjunction/predictive-studio-core';
24
+ import { NormalizeUUID, UUIDsEqual } from '@memberjunction/global';
25
+ import { RunView, LogError, LogStatus } from '@memberjunction/core';
26
+ import { EvaluationProtocolRules, InnerScoreSelection, UtcDay, PredictionUnit, TrainingRunResultsParser, TrustVerdicts, } from '@memberjunction/predictive-studio-core';
17
27
  import { ModelingPlanToPipelineConfig } from './modeling-plan-to-pipeline.js';
18
- import { trainModelViaEngine, wasTrainingLeakageFlagged } from '../operations/delegation.js';
19
- import { PredictiveStudioRefusals } from '../operations/refusals.js';
20
- /** How tournament candidates are scored, ranked and reported. Pure; no I/O. */
21
- export class TournamentRanking {
22
- /**
23
- * A candidate's leaderboard score: its trust verdict's headline metric, so the leaderboard and the headline can
24
- * never disagree for the same model. Null when the model was not measured.
25
- */
26
- static HeadlineScore(trust) {
27
- return trust.headlineMetric ? trust.headlineMetric.value : null;
28
- }
29
- /** Best-first: measured candidates by score (higher is better), unmeasured candidates last in plan order. */
30
- static Rank(trained) {
31
- return [...trained].sort((a, b) => {
32
- const sa = TournamentRanking.HeadlineScore(a.Trust);
33
- const sb = TournamentRanking.HeadlineScore(b.Trust);
34
- if (sa === null && sb === null)
35
- return 0;
36
- if (sa === null)
37
- return 1;
38
- if (sb === null)
39
- return -1;
40
- return sb - sa;
41
- });
42
- }
43
- /** Leaderboard rows for ranked candidates; the first row is the winner only when it was measured. */
44
- static Leaderboard(ranked) {
45
- return ranked.map((t, idx) => {
46
- const score = TournamentRanking.HeadlineScore(t.Trust);
47
- return {
48
- IterationID: t.Model.ID,
49
- Metric: score,
50
- ModelID: t.Model.ID,
51
- rank: idx + 1,
52
- algorithm: t.AlgorithmName,
53
- featureSet: t.FeatureSetName,
54
- score,
55
- metricName: t.Trust.headlineMetric ? t.Trust.headlineMetric.key : null,
56
- modelId: t.Model.ID,
57
- isWinner: idx === 0 && score !== null,
58
- };
59
- });
60
- }
61
- /**
62
- * The error a tournament throws when every candidate failed. When every candidate hit the same Predictive Studio
63
- * refusal, the first one is rethrown so its type and code survive; otherwise one error lists each distinct message.
64
- */
65
- static AllCandidatesFailed(errors) {
66
- const codes = errors.map((e) => PredictiveStudioRefusals.CodeOf(e));
67
- const first = codes[0];
68
- if (first !== null && first !== undefined && codes.every((c) => c === first)) {
69
- return errors[0];
70
- }
71
- const distinct = [...new Set(errors.map((e) => e.message))];
72
- return new Error(`All proposed experiment candidates failed to train: ${distinct.join(' | ')}`);
73
- }
28
+ import { TrainingDelegation, WasTrainingLeakageFlagged } from '../operations/delegation.js';
29
+ import { ProductionModelPromotionGate } from '../actions/promote-model.gate.js';
30
+ import { TrainerModelLineageReader } from '../training/trainer-model-lineage.js';
31
+ import { TrainingEngine } from '../training/training-engine.js';
32
+ import { MetadataEntityFactory } from '../training/seams.js';
33
+ import { EvaluationProtocolVersioning } from '../protocol/protocol-versioning.js';
34
+ import { ProtocolDefaults } from '../protocol/protocol-defaults.js';
35
+ import { RunViewDataAccess } from '../feature-assembly/data-access.js';
36
+ import { ProviderAssemblyMetadata } from '../feature-assembly/assembly-metadata.js';
37
+ import { PipelineMigration } from '../migration/legacy-pipeline-migration.js';
38
+ /** Baseline member names a candidate may not take (with the `heuristic:` prefix); the sidecar refuses them too. */
39
+ export const RESERVED_CANDIDATE_NAMES = ['dummy', 'oneFeature', 'glm', 'naive', 'seasonalNaive'];
40
+ /** The prefix of the incumbent-heuristic baseline members' names, reserved like {@link RESERVED_CANDIDATE_NAMES}. */
41
+ export const RESERVED_CANDIDATE_PREFIX = 'heuristic:';
42
+ /** Common short names an LLM writes for an algorithm, read as the normalized name of the algorithm they mean. */
43
+ const ALGORITHM_ALIASES = {
44
+ linearregression: 'ridgeregression',
45
+ linear: 'ridgeregression',
46
+ ols: 'ridgeregression',
47
+ ridge: 'ridgeregression',
48
+ logistic: 'logisticregression',
49
+ rf: 'randomforest',
50
+ lgb: 'lightgbm',
51
+ lgbm: 'lightgbm',
52
+ xgb: 'xgboost',
53
+ mlp: 'multilayerperceptron',
54
+ neuralnet: 'multilayerperceptron',
55
+ neuralnetwork: 'multilayerperceptron',
56
+ };
57
+ /** A name as the tolerant matchers compare it: lower-case letters and digits only (`Random Forest` → `randomforest`). */
58
+ function normalizeName(s) {
59
+ return (s || '').toLowerCase().replace(/[^a-z0-9]/g, '');
74
60
  }
75
61
  /** Deterministic builder: approved {@link ModelingPlanSpec} → pipeline + trained (+ maybe published) model. */
76
62
  export class PredictiveStudioPipelineBuilder {
77
63
  /**
78
- * Build a prediction from an approved plan: create the pipeline, train, and publish if the trust
79
- * verdict clears the bar. When multiple experiments are proposed, runs a multi-algorithm tournament
80
- * across up to 3 candidates, ranks them on each one's trust-verdict headline metric (unmeasured
81
- * candidates last, never the winner), and selects/publishes the winning model.
64
+ * Build a prediction from an approved plan: create one pipeline, bind its Prediction Unit, train it — one search
65
+ * over every approved experiment — and publish if the trust verdict clears the bar. Every experiment's name and algorithm are checked before any row is written.
82
66
  * Never throws — returns a typed result with `success`/`errorMessage`.
83
67
  */
84
68
  async Build(input) {
85
- const { spec, provider, user, autoPublish = true, sidecarVersion = 'predictive-studio-agent' } = input;
86
- const collectedWarnings = [];
87
- const seenWarningKeys = new Set();
88
- const recordWarnings = (warnings) => {
89
- for (const w of warnings) {
90
- const key = `${w.FeatureName}:${w.Kind}`;
91
- if (!seenWarningKeys.has(key)) {
92
- seenWarningKeys.add(key);
93
- collectedWarnings.push(w);
94
- }
95
- }
96
- };
69
+ const warnings = [];
97
70
  try {
98
- const experiments = (spec.ProposedExperiments && spec.ProposedExperiments.length > 0)
99
- ? [...spec.ProposedExperiments].sort((a, b) => (a.Priority ?? 0) - (b.Priority ?? 0))
100
- : [];
101
- if (experiments.length <= 1) {
102
- const config = ModelingPlanToPipelineConfig(spec);
103
- recordWarnings(config.warnings);
104
- const pipeline = await this.createPipeline(config, provider, user);
105
- const trainResult = await trainModelViaEngine({ pipelineId: pipeline.ID, sidecarVersion }, provider, user);
106
- const model = trainResult.model;
107
- const trust = TrustVerdicts.DeriveTrustVerdict(model);
108
- const leakageFlagged = wasTrainingLeakageFlagged(trainResult);
109
- const { published, heldReason } = await this.maybePublish(model, trust, leakageFlagged, autoPublish);
110
- const leaderboard = TournamentRanking.Leaderboard([{
111
- Pipeline: pipeline,
112
- Model: model,
113
- Trust: trust,
114
- LeakageFlagged: leakageFlagged,
115
- AlgorithmName: experiments[0]?.AlgorithmName ?? config.algorithmName,
116
- FeatureSetName: experiments[0]?.FeatureSet?.join(', ') || 'Full Feature Set',
117
- }]);
118
- return {
119
- success: true,
120
- pipelineId: pipeline.ID,
121
- modelId: model.ID,
122
- model,
123
- pipeline,
124
- trust,
125
- published,
126
- leakageFlagged,
127
- heldReason,
128
- errorMessage: null,
129
- leaderboard,
130
- warnings: collectedWarnings.length > 0 ? collectedWarnings : undefined,
131
- };
132
- }
133
- // Multi-algorithm tournament over up to 3 candidate experiments
134
- const candidatesToRun = experiments.slice(0, 3);
135
- const trained = [];
136
- const candidateErrors = [];
137
- for (let i = 0; i < candidatesToRun.length; i++) {
138
- const exp = candidatesToRun[i];
139
- try {
140
- const config = ModelingPlanToPipelineConfig(spec, i);
141
- recordWarnings(config.warnings);
142
- const pipeline = await this.createPipeline(config, provider, user);
143
- const trainResult = await trainModelViaEngine({ pipelineId: pipeline.ID, sidecarVersion }, provider, user);
144
- const model = trainResult.model;
145
- const trust = TrustVerdicts.DeriveTrustVerdict(model);
146
- const leakageFlagged = wasTrainingLeakageFlagged(trainResult);
147
- trained.push({
148
- Pipeline: pipeline,
149
- Model: model,
150
- Trust: trust,
151
- LeakageFlagged: leakageFlagged,
152
- AlgorithmName: exp.AlgorithmName || config.algorithmName,
153
- FeatureSetName: exp.FeatureSet?.join(', ') || 'Full Feature Set',
154
- });
155
- }
156
- catch (candidateErr) {
157
- const error = candidateErr instanceof Error ? candidateErr : new Error(String(candidateErr));
158
- candidateErrors.push(error);
159
- LogError(`PredictiveStudioPipelineBuilder: candidate '${exp.AlgorithmName}' failed: ${error.message}`);
160
- }
161
- }
162
- if (trained.length === 0) {
163
- throw TournamentRanking.AllCandidatesFailed(candidateErrors);
164
- }
165
- // Measured candidates best-first, unmeasured last. When none was measured there is no winner: the result
166
- // still reports the top-priority candidate (held by the trust gate, which never lets an unmeasured model act).
167
- const ranked = TournamentRanking.Rank(trained);
168
- const winner = ranked[0];
169
- const { published, heldReason } = await this.maybePublish(winner.Model, winner.Trust, winner.LeakageFlagged, autoPublish);
170
- const leaderboard = TournamentRanking.Leaderboard(ranked);
171
- return {
172
- success: true,
173
- pipelineId: winner.Pipeline.ID,
174
- modelId: winner.Model.ID,
175
- model: winner.Model,
176
- pipeline: winner.Pipeline,
177
- trust: winner.Trust,
178
- published,
179
- leakageFlagged: winner.LeakageFlagged,
180
- heldReason,
181
- errorMessage: null,
182
- leaderboard,
183
- warnings: collectedWarnings.length > 0 ? collectedWarnings : undefined,
184
- };
71
+ return await this.runBuild(input, warnings);
185
72
  }
186
73
  catch (err) {
187
74
  const errorMessage = err instanceof Error ? err.message : String(err);
@@ -189,22 +76,230 @@ export class PredictiveStudioPipelineBuilder {
189
76
  return {
190
77
  success: false,
191
78
  published: false,
79
+ readyToPublish: false,
192
80
  leakageFlagged: false,
193
81
  heldReason: null,
194
82
  errorMessage,
195
- warnings: collectedWarnings.length > 0 ? collectedWarnings : undefined,
83
+ warnings: warnings.length > 0 ? warnings : undefined,
196
84
  };
197
85
  }
198
86
  }
199
- /** @deprecated Use {@link Build}. */
200
- async build(input) {
201
- return this.Build(input);
87
+ /**
88
+ * The build's steps — resolve the plan, save and bind the pipeline, train one search, publish when the verdict
89
+ * clears the bar. Throws on any failure; the plan's feature-step warnings go into `warnings` first, so the failure
90
+ * result {@link Build} returns still carries them.
91
+ */
92
+ async runBuild(input, warnings) {
93
+ const { spec, provider, user, autoPublish = true, sidecarVersion = 'predictive-studio-agent' } = input;
94
+ const config = ModelingPlanToPipelineConfig(spec);
95
+ warnings.push(...PredictiveStudioPipelineBuilder.DistinctWarnings(config.warnings));
96
+ const { Pipeline: pipeline, Candidates: candidates } = await this.createBoundPipeline(spec, config, provider, user);
97
+ const training = await this.trainSearch(pipeline, candidates, sidecarVersion, provider, user);
98
+ const model = training.Train.model;
99
+ if (model === null)
100
+ return PredictiveStudioPipelineBuilder.heldWithoutModel(pipeline, training, warnings);
101
+ const trust = TrustVerdicts.DeriveTrustVerdict({ ValidationResults: training.Train.run.ValidationResults, Lineage: model.Lineage });
102
+ const leakageFlagged = WasTrainingLeakageFlagged(training.Train);
103
+ const { published, heldReason, readyToPublish } = await this.maybePublish({ Model: model, Trust: trust, LeakageFlagged: leakageFlagged, AutoPublish: autoPublish, Provider: provider, User: user });
104
+ return {
105
+ success: true, pipelineId: pipeline.ID, modelId: model.ID, model, pipeline, trust, published, readyToPublish, leakageFlagged, heldReason,
106
+ errorMessage: null, leaderboard: training.Leaderboard, Gate: training.Gate || undefined,
107
+ warnings: warnings.length > 0 ? warnings : undefined,
108
+ };
109
+ }
110
+ /** The warnings with one entry per feature and kind, first occurrence kept. */
111
+ static DistinctWarnings(warnings) {
112
+ const seen = new Set();
113
+ return warnings.filter((w) => {
114
+ const key = `${w.FeatureName}:${w.Kind}`;
115
+ if (seen.has(key))
116
+ return false;
117
+ seen.add(key);
118
+ return true;
119
+ });
120
+ }
121
+ /**
122
+ * Checks every approved experiment's name and algorithm, then saves the pipeline and binds its Prediction Unit; no
123
+ * row is written before the checks pass. Returns the saved pipeline and the search's candidates.
124
+ */
125
+ async createBoundPipeline(spec, config, provider, user) {
126
+ const entity = this.preparePipelineConfig(config, provider);
127
+ const approved = PredictiveStudioPipelineBuilder.ApprovedExperiments(spec);
128
+ const algorithms = await this.resolveAlgorithms([config.algorithmName, ...approved.map((e) => e.AlgorithmName)], provider, user);
129
+ const candidates = PredictiveStudioPipelineBuilder.BuildCandidateSpecs(approved, algorithms);
130
+ if (approved.some((e) => (e.FeatureSet || []).length > 0)) {
131
+ LogStatus('PredictiveStudioPipelineBuilder: per-experiment feature sets are not candidates of one search; every candidate uses the pipeline feature schema.');
132
+ }
133
+ const pipeline = await this.savePipeline(config, entity, PredictiveStudioPipelineBuilder.algorithmOf(algorithms, config.algorithmName).ID, provider, user);
134
+ await PredictiveStudioPipelineBuilder.bindUnit(pipeline, provider, user);
135
+ return { Pipeline: pipeline, Candidates: candidates };
136
+ }
137
+ /**
138
+ * The result of a build whose training run shipped no model (the gate decided `no-signal`, or kept the unit's existing
139
+ * rule): built, not published, held with the run's stored reason, and no trust verdict (there is no model to judge).
140
+ */
141
+ static heldWithoutModel(pipeline, training, warnings) {
142
+ return {
143
+ success: true, pipelineId: pipeline.ID, pipeline, published: false, readyToPublish: false, leakageFlagged: WasTrainingLeakageFlagged(training.Train),
144
+ heldReason: `Not published — the training run shipped no model: ${TrainingEngine.NoModelReason(training.Train)}`,
145
+ errorMessage: null, leaderboard: training.Leaderboard, Gate: training.Gate || undefined,
146
+ warnings: warnings.length > 0 ? warnings : undefined,
147
+ };
148
+ }
149
+ /** The plan's proposed experiments, highest priority (lowest `Priority`) first; ties keep plan order. */
150
+ static ApprovedExperiments(spec) {
151
+ return [...(spec.ProposedExperiments || [])]
152
+ .sort((a, b) => (a.Priority || 0) - (b.Priority || 0))
153
+ .map((e) => ({ ...e, AlgorithmName: e.AlgorithmName.trim() }));
154
+ }
155
+ /**
156
+ * Every approved experiment becomes one candidate of the single search, in plan-priority order. A label a baseline
157
+ * member uses (or one with the heuristic prefix) and a label used twice are refused, as is an algorithm name that
158
+ * was not resolved. Hyperparameters keep their scalar values; nested objects are dropped.
159
+ *
160
+ * @throws Error naming the experiment
161
+ */
162
+ static BuildCandidateSpecs(experiments, algorithms) {
163
+ const seen = new Set();
164
+ return experiments.map((e) => {
165
+ if (RESERVED_CANDIDATE_NAMES.includes(e.Label) || e.Label.startsWith(RESERVED_CANDIDATE_PREFIX)) {
166
+ throw new Error(`Experiment label '${e.Label}' is reserved for a baseline member; rename the experiment.`);
167
+ }
168
+ if (seen.has(e.Label))
169
+ throw new Error(`Experiment label '${e.Label}' is used by two experiments; every candidate of a search needs its own name.`);
170
+ seen.add(e.Label);
171
+ const algorithm = PredictiveStudioPipelineBuilder.algorithmOf(algorithms, e.AlgorithmName);
172
+ return { name: e.Label, algorithmId: algorithm.ID, driverKey: algorithm.DriverClass, hyperparameters: PredictiveStudioPipelineBuilder.scalarHyperparameters(e.Hyperparameters) };
173
+ });
174
+ }
175
+ /**
176
+ * The `MJ: ML Algorithms` row an algorithm name means. Tolerant of LLM naming variation: the display `Name` or the
177
+ * `DriverClass` matches case- and separator-insensitively, and common short names (`rf`, `xgb`, `linear`, …) are
178
+ * read as the algorithm they name. Two different rows that both match are refused rather than one being picked.
179
+ *
180
+ * @throws Error listing the available algorithms when nothing matches, or naming both rows when two match
181
+ */
182
+ static MatchAlgorithm(algorithmName, rows) {
183
+ const normalized = normalizeName(algorithmName);
184
+ const want = ALGORITHM_ALIASES[normalized] || normalized;
185
+ const matches = rows.filter((a) => normalizeName(a.Name) === want || normalizeName(a.DriverClass) === want);
186
+ if (matches.length === 0) {
187
+ const available = rows.map((a) => a.Name).join(', ');
188
+ throw new Error(`Algorithm '${algorithmName}' was not found in MJ: ML Algorithms. Available: ${available || '(none)'}.`);
189
+ }
190
+ if (matches.length > 1) {
191
+ const named = matches.map((a) => `'${a.Name}' (${a.DriverClass}, ${NormalizeUUID(a.ID)})`).join(' and ');
192
+ throw new Error(`Algorithm '${algorithmName}' matches more than one MJ: ML Algorithms row: ${named}; name the algorithm by one of them.`);
193
+ }
194
+ return { ID: matches[0].ID, DriverClass: matches[0].DriverClass };
195
+ }
196
+ /** The resolved algorithm of a name, which {@link resolveAlgorithms} resolved before any row was written. */
197
+ static algorithmOf(algorithms, name) {
198
+ const algorithm = algorithms.get(name);
199
+ if (algorithm === undefined)
200
+ throw new Error(`Algorithm '${name}' was not resolved.`);
201
+ return algorithm;
202
+ }
203
+ /** A plan experiment's hyperparameters as candidate values: scalars and null kept, nested objects and arrays dropped. */
204
+ static scalarHyperparameters(raw) {
205
+ const hyperparameters = {};
206
+ for (const [key, value] of Object.entries(raw || {})) {
207
+ if (PredictiveStudioPipelineBuilder.isHyperparameterValue(value))
208
+ hyperparameters[key] = value;
209
+ }
210
+ return hyperparameters;
211
+ }
212
+ /** A scalar or null: the values a candidate's hyperparameter can hold. */
213
+ static isHyperparameterValue(value) {
214
+ return value === null || typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean';
215
+ }
216
+ /**
217
+ * Bind version 1 of the pipeline's Prediction Unit, mapped from the columns the plan wrote (the pipeline migration's
218
+ * mapping), right after the pipeline is saved; its search protocol is bound later, for every candidate. A pipeline
219
+ * the mapping would archive or hold is refused with the mapping's reason, and the pipeline just saved is deleted: no
220
+ * pipeline trains without a unit, and the build leaves no unit-less Draft behind.
221
+ *
222
+ * @throws Error naming why the pipeline gets no unit (and the pipeline's ID when deleting it failed)
223
+ */
224
+ static async bindUnit(pipeline, provider, user) {
225
+ const deps = { Provider: provider, User: user, EntityFactory: new MetadataEntityFactory(provider), Today: UtcDay.UtcDayIso(new Date()) };
226
+ const bound = await PipelineMigration.BindMigratedUnit(pipeline, deps);
227
+ if (bound.Ok === true)
228
+ return;
229
+ const id = pipeline.ID;
230
+ if (await pipeline.Delete())
231
+ throw new Error(`The pipeline gets no Prediction Unit, so it cannot train and was not kept: ${bound.Reason}`);
232
+ throw new Error(`The pipeline gets no Prediction Unit, so it cannot train (${bound.Reason}); deleting pipeline ${id} failed: ${pipeline.LatestResult?.CompleteMessage || 'Delete() returned false'}`);
202
233
  }
203
- /** Create + save the `MJ: ML Training Pipelines` row from the resolved config. */
204
- async createPipeline(config, provider, user) {
205
- // Validate the whole plan against real metadata BEFORE creating any rows or training — so an invalid
206
- // plan (bad entity / target / feature / algorithm) fails fast with an actionable message and leaves
207
- // no orphan pipeline/run rows behind, instead of erroring mid-train.
234
+ /**
235
+ * Train a pipeline with a Prediction Unit: bind its default Evaluation Protocol (before the run row), run ONE search
236
+ * over every candidate, and read the leaderboard from the stored inner-fold scores and the gate decision from the stored record.
237
+ */
238
+ async trainSearch(pipeline, candidates, sidecarVersion, provider, user) {
239
+ await this.ensureProtocol(pipeline, candidates.length, provider, user);
240
+ const train = await TrainingDelegation.TrainModelViaEngine({ pipelineId: pipeline.ID, candidates, sidecarVersion }, provider, user);
241
+ return { Train: train, ...PredictiveStudioPipelineBuilder.searchResults(train) };
242
+ }
243
+ /**
244
+ * A search's leaderboard from the run's stored trainer result: every candidate best-first by inner-fold mean with its
245
+ * interval, each optimistic, the trainer's finalist the winner. The finalist's row links the model only when the gate
246
+ * shipped the finalist; a kept baseline member's model, or no model, links no candidate row. With it, the stored
247
+ * gate decision (outcome and reason), so a reader of the leaderboard knows whether the finalist shipped.
248
+ *
249
+ * @throws Error when the completed run stores no trainer result
250
+ */
251
+ static searchResults(train) {
252
+ const results = TrainingRunResultsParser.ParseTrainingRunResults(train.run.ValidationResults);
253
+ if (!results.Ok || results.Value.status !== 'completed' || results.Value.trainer === null) {
254
+ throw new Error(`Training run ${train.run.ID} completed without a stored trainer result; its search has no leaderboard.`);
255
+ }
256
+ const trainer = results.Value.trainer;
257
+ const gate = results.Value.gate;
258
+ const finalistModelId = train.model !== null && gate !== null && gate.decision.outcome === 'model' ? train.model.ID : undefined;
259
+ const leaderboard = InnerScoreSelection.LeaderboardFromInnerScores(trainer.innerScores, trainer.finalist).map((row) => ({
260
+ IterationID: train.run.ID, Metric: row.Mean, ModelID: row.IsFinalist ? finalistModelId : undefined, rank: row.Rank, algorithm: row.Candidate,
261
+ featureSet: 'Pipeline feature set', score: row.Mean, metricName: row.Metric, innerLower: row.Lower, innerUpper: row.Upper,
262
+ optimistic: row.Optimistic, modelId: row.IsFinalist ? finalistModelId : undefined, isWinner: row.IsFinalist,
263
+ }));
264
+ return { Leaderboard: leaderboard, Gate: gate === null ? null : { Outcome: gate.decision.outcome, Reason: gate.reason.text } };
265
+ }
266
+ /**
267
+ * Resolve each distinct algorithm name once over one read of `MJ: ML Algorithms` (keys are the names as written in
268
+ * the plan), so a bad name fails before any row is written.
269
+ */
270
+ async resolveAlgorithms(names, provider, user) {
271
+ const rv = RunView.FromMetadataProvider(provider);
272
+ const res = await rv.RunView({ EntityName: 'MJ: ML Algorithms', Fields: ['ID', 'Name', 'DriverClass'], ResultType: 'simple' }, user);
273
+ if (!res.Success)
274
+ throw new Error(`Loading MJ: ML Algorithms failed: ${res.ErrorMessage}`);
275
+ return new Map([...new Set(names)].map((name) => [name, PredictiveStudioPipelineBuilder.MatchAlgorithm(name, res.Results)]));
276
+ }
277
+ /**
278
+ * Bind version 1 of a default Evaluation Protocol when the pipeline has none — always before the first candidate
279
+ * trains, so the protocol row precedes the run row. The holdout is the unit's default ({@link ProtocolDefaults}).
280
+ */
281
+ async ensureProtocol(pipeline, candidates, provider, user) {
282
+ if (pipeline.EvaluationProtocolID)
283
+ return;
284
+ const unitRow = await provider.GetEntityObject('MJ: ML Prediction Units', user);
285
+ if (!pipeline.PredictionUnitID || !(await unitRow.Load(pipeline.PredictionUnitID)))
286
+ throw new Error(`Prediction Unit ${pipeline.PredictionUnitID || '(none)'} not found.`);
287
+ const parsed = PredictionUnit.ParsePredictionUnitRow(unitRow);
288
+ if (parsed.Ok === false)
289
+ throw new Error(`Prediction Unit cannot be read: ${parsed.Errors.join('; ')}`);
290
+ const holdout = await ProtocolDefaults.DefaultHoldoutFor(parsed.Value, { DataAccess: new RunViewDataAccess(user, provider), Metadata: new ProviderAssemblyMetadata(provider), Now: new Date() });
291
+ const draft = EvaluationProtocolRules.DefaultEvaluationProtocolDraft({ Unit: parsed.Value, Holdout: holdout, Candidates: candidates, Seed: ProtocolDefaults.DEFAULT_SEED, Name: `${pipeline.Name} — protocol` });
292
+ const row = await EvaluationProtocolVersioning.CreateEvaluationProtocolV1(draft, { kind: 'system', component: 'pipeline-builder' }, new MetadataEntityFactory(provider), user);
293
+ pipeline.EvaluationProtocolID = row.ID;
294
+ if (!(await pipeline.Save()))
295
+ throw new Error(`Binding the Evaluation Protocol failed: ${pipeline.LatestResult?.CompleteMessage || 'unknown error'}`);
296
+ }
297
+ /**
298
+ * Validate the whole plan against real metadata BEFORE any row is written or anything trains — so an invalid plan
299
+ * (bad entity / target / feature) fails fast with an actionable message and leaves no orphan pipeline or run rows
300
+ * behind — and canonicalize its names. Returns the target entity.
301
+ */
302
+ preparePipelineConfig(config, provider) {
208
303
  const entity = ResolveEntity(config.targetEntityName, provider);
209
304
  if (!entity) {
210
305
  throw new Error(`Target entity '${config.targetEntityName}' was not found in metadata. The plan must reference a real entity.`);
@@ -220,15 +315,17 @@ export class PredictiveStudioPipelineBuilder {
220
315
  // Sanitize leakage guard deny fields against real entity schema
221
316
  this.sanitizeLeakageGuard(config, entity, provider);
222
317
  this.validatePlanFields(config, entity);
223
- const targetEntityId = entity.ID;
224
- const algorithmId = await this.resolveAlgorithmId(config.algorithmName, provider, user);
318
+ return entity;
319
+ }
320
+ /** Create + save the `MJ: ML Training Pipelines` row from the validated config. */
321
+ async savePipeline(config, entity, algorithmId, provider, user) {
225
322
  const pipeline = await provider.GetEntityObject('MJ: ML Training Pipelines', user);
226
323
  pipeline.NewRecord();
227
324
  pipeline.Name = config.name;
228
325
  pipeline.Description = config.description;
229
326
  pipeline.Version = 1;
230
327
  pipeline.Status = 'Draft';
231
- pipeline.TargetEntityID = targetEntityId;
328
+ pipeline.TargetEntityID = entity.ID;
232
329
  pipeline.TargetVariable = config.targetVariable;
233
330
  pipeline.ProblemType = config.problemType;
234
331
  pipeline.AlgorithmID = algorithmId;
@@ -332,61 +429,68 @@ export class PredictiveStudioPipelineBuilder {
332
429
  }
333
430
  }
334
431
  /**
335
- * Resolve an algorithm reference to its `MJ: ML Algorithms` id. Tolerant of LLM
336
- * naming variation: matches the display `Name` OR the `DriverClass`, comparing
337
- * case- and separator-insensitively — so `'LogisticRegression'`,
338
- * `'Logistic Regression'`, and `'logistic_regression'` all resolve to the same row.
339
- * Throws with the available algorithm list if nothing matches.
432
+ * Publish the trained model into the business catalog ONLY if auto-publish is on, training wasn't leakage-flagged,
433
+ * the model holds no calibration hold and the trust verdict clears the bar, and then only through the promotion
434
+ * gate ({@link publishThroughGate}). Otherwise the model stays where it is and the plain held-reason is returned.
340
435
  */
341
- async resolveAlgorithmId(algorithmName, provider, user) {
342
- const rv = RunView.FromMetadataProvider(provider);
343
- const res = await rv.RunView({ EntityName: 'MJ: ML Algorithms', Fields: ['ID', 'Name', 'DriverClass'], ResultType: 'simple' }, user);
344
- const algos = res.Success ? res.Results ?? [] : [];
345
- const normalize = (s) => (s ?? '').toLowerCase().replace(/[^a-z0-9]/g, '');
346
- let want = normalize(algorithmName);
347
- const ALIASES = {
348
- linearregression: 'ridgeregression',
349
- linear: 'ridgeregression',
350
- ols: 'ridgeregression',
351
- ridge: 'ridgeregression',
352
- logistic: 'logisticregression',
353
- rf: 'randomforest',
354
- lgb: 'lightgbm',
355
- lgbm: 'lightgbm',
356
- xgb: 'xgboost',
357
- mlp: 'multilayerperceptron',
358
- neuralnet: 'multilayerperceptron',
359
- neuralnetwork: 'multilayerperceptron',
360
- };
361
- if (ALIASES[want]) {
362
- want = ALIASES[want];
363
- }
364
- const match = algos.find((a) => normalize(a.Name) === want || normalize(a.DriverClass) === want);
365
- if (!match) {
366
- const available = algos.map((a) => a.Name).join(', ');
367
- throw new Error(`Algorithm '${algorithmName}' was not found in MJ: ML Algorithms. Available: ${available || '(none)'}.`);
368
- }
369
- return match.ID;
436
+ async maybePublish(p) {
437
+ const held = PredictiveStudioPipelineBuilder.heldBeforePromotion(p);
438
+ if (held !== null)
439
+ return { published: false, heldReason: held, readyToPublish: false };
440
+ if (!p.AutoPublish)
441
+ return { published: false, heldReason: PredictiveStudioPipelineBuilder.KeptInDraftReason, readyToPublish: true };
442
+ return this.publishThroughGate(p.Model, p.Provider, p.User);
370
443
  }
444
+ /** The held reason of a model that clears the bar to publish and stays in Draft only because auto-publish was off. */
445
+ static { this.KeptInDraftReason = 'Kept in Draft — it clears the bar to publish, and is published only when you ask.'; }
371
446
  /**
372
- * Publish the trained model into the business catalog ONLY if the trust verdict clears the bar and
373
- * training wasn't leakage-flagged. Otherwise leave it Draft and return the plain held-reason.
447
+ * Why a trained model cannot be published; null when the promotion gate may be asked to publish it. Auto-publish is
448
+ * not one of these reasons: a model that is off only for that is ready to publish ({@link maybePublish}).
374
449
  */
375
- async maybePublish(model, trust, leakageFlagged, autoPublish) {
376
- if (!autoPublish) {
377
- return { published: false, heldReason: 'Not published — auto-publish was off; review and publish when ready.' };
378
- }
379
- if (leakageFlagged) {
380
- return { published: false, heldReason: 'Held for analyst review — training flagged a possible data-leakage issue.' };
450
+ static heldBeforePromotion(p) {
451
+ if (p.LeakageFlagged)
452
+ return 'Held for analyst review — training flagged a possible data-leakage issue.';
453
+ const hold = TrainerModelLineageReader.CalibrationHoldOf(p.Model.Lineage);
454
+ if (hold !== null) {
455
+ return `Held — ${ProductionModelPromotionGate.DescribeRefusal({ kind: 'refused-calibration', slope: hold.slope })}; a hidden family is never published.`;
381
456
  }
382
- if (!trust.canAct) {
383
- return { published: false, heldReason: trust.gateReason ?? 'Held — this prediction is not reliable enough to publish yet.' };
457
+ return p.Trust.CanAct ? null : p.Trust.Reason;
458
+ }
459
+ /**
460
+ * Move the model Draft → Validated → Published through the promotion gate with no sign-off, so the gate's leakage,
461
+ * calibration and readiness checks apply and it generates the per-model scoring Action. A refusal holds the model at
462
+ * the status the gate left it, with the gate's reason. The gate saves its own copy of the row, so the returned model
463
+ * is reloaded once anything moved and reads the status the gate stored.
464
+ */
465
+ async publishThroughGate(model, provider, user) {
466
+ const gate = this.CreatePromotionGate();
467
+ let result = { published: true, heldReason: null, readyToPublish: false };
468
+ let moved = false;
469
+ for (const targetStatus of ['Validated', 'Published']) {
470
+ const outcome = await gate.promote({ modelId: model.ID, targetStatus, signOff: false, contextUser: user, provider });
471
+ if (outcome.kind !== 'promoted') {
472
+ const reason = ProductionModelPromotionGate.DescribeRefusal(outcome);
473
+ result = { published: false, heldReason: `Not published — the promotion gate refused to move it to ${targetStatus}: ${reason}${reason.endsWith('.') ? '' : '.'}`, readyToPublish: false };
474
+ break;
475
+ }
476
+ moved = true;
384
477
  }
385
- model.Status = 'Published';
386
- if (!(await model.Save())) {
387
- throw new Error(`Trained model could not be published: ${model.LatestResult?.CompleteMessage ?? 'unknown error'}`);
478
+ if (moved)
479
+ await PredictiveStudioPipelineBuilder.reloadModel(model);
480
+ return result;
481
+ }
482
+ /** Read the model row back after the gate changed it; a failed read is logged (the promotion itself succeeded). */
483
+ static async reloadModel(model) {
484
+ if (!(await model.Load(model.ID))) {
485
+ LogError(`PredictiveStudioPipelineBuilder: model ${model.ID} was promoted but could not be read back: ${model.LatestResult?.CompleteMessage || 'unknown error'}`);
388
486
  }
389
- return { published: true, heldReason: null };
487
+ }
488
+ /**
489
+ * The promotion gate the build publishes through: the production {@link ProductionModelPromotionGate}, the same gate
490
+ * the Promote action, operation and auto-train use. Overridable so tests inject a gate with no live DB.
491
+ */
492
+ CreatePromotionGate() {
493
+ return new ProductionModelPromotionGate();
390
494
  }
391
495
  }
392
496
  /**
@@ -402,8 +506,7 @@ export function ResolveEntity(nameOrView, provider) {
402
506
  if (direct)
403
507
  return direct;
404
508
  const trimmed = nameOrView.trim().toLowerCase();
405
- const normalize = (s) => (s ?? '').toLowerCase().replace(/[^a-z0-9]/g, '');
406
- const normalizedTarget = normalize(nameOrView);
509
+ const normalizedTarget = normalizeName(nameOrView);
407
510
  for (const e of provider.Entities) {
408
511
  if (e.Name.trim().toLowerCase() === trimmed)
409
512
  return e;
@@ -415,20 +518,16 @@ export function ResolveEntity(nameOrView, provider) {
415
518
  return e;
416
519
  if (e.SchemaName && e.BaseTable && `${e.SchemaName}.${e.BaseTable}`.trim().toLowerCase() === trimmed)
417
520
  return e;
418
- if (normalize(e.Name) === normalizedTarget)
521
+ if (normalizeName(e.Name) === normalizedTarget)
419
522
  return e;
420
- if (e.BaseView && normalize(e.BaseView) === normalizedTarget)
523
+ if (e.BaseView && normalizeName(e.BaseView) === normalizedTarget)
421
524
  return e;
422
- if (e.BaseTable && normalize(e.BaseTable) === normalizedTarget)
525
+ if (e.BaseTable && normalizeName(e.BaseTable) === normalizedTarget)
423
526
  return e;
424
527
  const strippedPrefix = e.Name.replace(/^[^:]+:\s*/, '').trim().toLowerCase();
425
- if (strippedPrefix === trimmed || normalize(strippedPrefix) === normalizedTarget)
528
+ if (strippedPrefix === trimmed || normalizeName(strippedPrefix) === normalizedTarget)
426
529
  return e;
427
530
  }
428
531
  return undefined;
429
532
  }
430
- /** @deprecated Use {@link ResolveEntity}. */
431
- export function resolveEntity(nameOrView, provider) {
432
- return ResolveEntity(nameOrView, provider);
433
- }
434
533
  //# sourceMappingURL=pipeline-builder.js.map