@memberjunction/predictive-studio 6.2.1 → 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
@@ -1 +1 @@
1
- {"version":3,"file":"seams.js","sourceRoot":"","sources":["../../src/training/seams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH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/ps-storage-provider.js';
2
+ import type { IArtifactStore, IEntityFactory } from './types.js';
3
+ /** {@link IArtifactStore} over the configured MJ storage provider. */
4
+ export declare class StorageProviderArtifactStore implements IArtifactStore {
5
+ private readonly entityFactory;
6
+ private readonly storage;
7
+ /** The key prefix every model artifact object is stored under. */
8
+ static readonly KEY_PREFIX = "predictive-studio/model-artifacts";
9
+ /** The object name of the write probe {@link AssertWritable} puts and deletes. */
10
+ private static readonly PROBE_NAME;
11
+ /**
12
+ * @param entityFactory creates and loads the `MJ: Files` rows
13
+ * @param storage the storage provider the objects are written to and the providers stored rows name
14
+ */
15
+ constructor(entityFactory: IEntityFactory, storage: PredictiveStudioStorage);
16
+ /**
17
+ * Proves the configured provider can write here: resolves its driver, puts a small probe object at
18
+ * `<KEY_PREFIX>/<fresh UUID>/.probe`, then deletes it. A probe that is written but cannot be deleted does not refuse
19
+ * (the provider can write); it is logged as a warning naming the object left behind.
20
+ *
21
+ * @throws Error naming the provider and `PS_STORAGE_PROVIDER` when no provider has that name, its driver is not
22
+ * configured here, or the probe write is refused or fails
23
+ */
24
+ AssertWritable(): Promise<void>;
25
+ /**
26
+ * Stores the bytes under a fresh key and records the `MJ: Files` row.
27
+ *
28
+ * @throws Error when the name is not one safe key segment (before anything is stored), when storage refuses the
29
+ * object, or when the row cannot be saved (the object is removed first)
30
+ */
31
+ save(bytes: Uint8Array, name: string): Promise<string>;
32
+ /**
33
+ * Removes an artifact: its object (through the provider its row names), then its row. A legacy row's local file is
34
+ * removed after the row.
35
+ *
36
+ * @throws Error when the row is not found, the object cannot be removed (the row is kept), or the row cannot be deleted
37
+ */
38
+ delete(fileId: string): Promise<void>;
39
+ private deleteObject;
40
+ /** `<KEY_PREFIX>/<fresh UUID>/<name>`; refuses a name that is not one safe key segment. */
41
+ private static objectKeyFor;
42
+ /** Why the probe could not be written, or null when it was. */
43
+ private static probeWriteFailure;
44
+ /** Deletes the write probe; a failure is logged as a warning, since the write it proved succeeded. */
45
+ private static removeProbe;
46
+ /** Removes an object whose row could not be saved; a failure is logged, since the row's error is the one thrown. */
47
+ private static removeUnrecordedObject;
48
+ }
49
+ //# sourceMappingURL=storage-provider-artifact-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-provider-artifact-store.d.ts","sourceRoot":"","sources":["../../src/training/storage-provider-artifact-store.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,uBAAuB,EAA6B,MAAM,gCAAgC,CAAC;AAEpG,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D,sEAAsE;AACtE,qBAAa,4BAA6B,YAAW,cAAc;IAUrD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAAkB,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpF,kEAAkE;IAClE,gBAAuB,UAAU,uCAAuC;IACxE,kFAAkF;IAClF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAY;IAE9C;;;OAGG;gBAC0B,aAAa,EAAE,cAAc,EAAmB,OAAO,EAAE,uBAAuB;IAE7G;;;;;;;OAOG;IACU,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5C;;;;;OAKG;IACU,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmBnE;;;;;OAKG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAcpC,YAAY;IAO1B,2FAA2F;IAC3F,OAAO,CAAC,MAAM,CAAC,YAAY;IAQ3B,+DAA+D;mBAC1C,iBAAiB;IAStC,sGAAsG;mBACjF,WAAW;IAYhC,oHAAoH;mBAC/F,sBAAsB;CAW5C"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @module training/storage-provider-artifact-store
3
+ *
4
+ * Trained model files in the MJ storage provider every Predictive Studio file is written to
5
+ * ({@link PredictiveStudioStorage}: `PS_STORAGE_PROVIDER`, default "Local File System"). Each artifact is an object
6
+ * under `predictive-studio/model-artifacts/<fresh UUID>/<name>` and an `MJ: Files` row naming its provider and key.
7
+ *
8
+ * Every save gets a fresh key, so no other save shares its object: a save whose `MJ: Files` row fails removes the
9
+ * object it just wrote, and a rollback ({@link StorageProviderArtifactStore.Delete}) removes the object, then the row.
10
+ * Rows are written and read as the user of the {@link PredictiveStudioStorage} the store is built over.
11
+ *
12
+ * A model `MJ: Files` row with an empty `ProviderKey` was written before model files went through the storage provider:
13
+ * its bytes are on local disk at `LocalArtifactPath(ResolveLocalArtifactBaseDir(), fileId)` (`PS_ARTIFACT_DIR`), and
14
+ * `Delete` removes that file with the row.
15
+ */
16
+ import { randomUUID } from 'node:crypto';
17
+ import { rm } from 'node:fs/promises';
18
+ import { LogError, LogWarning } from '@memberjunction/core';
19
+ import { IsSafeStorageObjectKey } from '@memberjunction/storage';
20
+ import { PredictiveStudioStorage } from '../storage/ps-storage-provider.js';
21
+ import { LocalArtifactPath, ResolveLocalArtifactBaseDir } from './artifact-store.js';
22
+ /** {@link IArtifactStore} over the configured MJ storage provider. */
23
+ export class StorageProviderArtifactStore {
24
+ /** The key prefix every model artifact object is stored under. */
25
+ static { this.KEY_PREFIX = 'predictive-studio/model-artifacts'; }
26
+ /** The object name of the write probe {@link AssertWritable} puts and deletes. */
27
+ static { this.PROBE_NAME = '.probe'; }
28
+ /**
29
+ * @param entityFactory creates and loads the `MJ: Files` rows
30
+ * @param storage the storage provider the objects are written to and the providers stored rows name
31
+ */
32
+ constructor(entityFactory, storage) {
33
+ this.entityFactory = entityFactory;
34
+ this.storage = storage;
35
+ }
36
+ /**
37
+ * Proves the configured provider can write here: resolves its driver, puts a small probe object at
38
+ * `<KEY_PREFIX>/<fresh UUID>/.probe`, then deletes it. A probe that is written but cannot be deleted does not refuse
39
+ * (the provider can write); it is logged as a warning naming the object left behind.
40
+ *
41
+ * @throws Error naming the provider and `PS_STORAGE_PROVIDER` when no provider has that name, its driver is not
42
+ * configured here, or the probe write is refused or fails
43
+ */
44
+ async AssertWritable() {
45
+ const binding = await this.storage.ConfiguredDriver();
46
+ const probeKey = `${StorageProviderArtifactStore.KEY_PREFIX}/${randomUUID()}/${StorageProviderArtifactStore.PROBE_NAME}`;
47
+ const failure = await StorageProviderArtifactStore.probeWriteFailure(binding, probeKey);
48
+ if (failure !== null) {
49
+ throw new Error(`Predictive Studio storage: storage provider "${binding.Provider.Name}" cannot write here (probe ${probeKey}: ${failure}) ` +
50
+ `(${PredictiveStudioStorage.ENV_VAR} names the provider Predictive Studio files are written to)`);
51
+ }
52
+ await StorageProviderArtifactStore.removeProbe(binding, probeKey);
53
+ }
54
+ /**
55
+ * Stores the bytes under a fresh key and records the `MJ: Files` row.
56
+ *
57
+ * @throws Error when the name is not one safe key segment (before anything is stored), when storage refuses the
58
+ * object, or when the row cannot be saved (the object is removed first)
59
+ */
60
+ async save(bytes, name) {
61
+ const objectKey = StorageProviderArtifactStore.objectKeyFor(name);
62
+ const contentType = name.toLowerCase().endsWith('.json') ? 'application/json' : 'application/octet-stream';
63
+ const binding = await this.storage.ConfiguredDriver();
64
+ if (!(await binding.Driver.PutObject(objectKey, Buffer.from(bytes), contentType))) {
65
+ throw new Error(`Predictive Studio model artifacts: storage provider "${binding.Provider.Name}" refused ${objectKey}`);
66
+ }
67
+ const row = await this.storage.SaveFileRow(binding, { ObjectKey: objectKey, Name: name, ContentType: contentType, Detail: `Predictive Studio model artifact (${bytes.byteLength} bytes)` }, this.entityFactory);
68
+ if (row.Saved === false) {
69
+ await StorageProviderArtifactStore.removeUnrecordedObject(binding, objectKey);
70
+ throw new Error(`Predictive Studio model artifacts: saving the MJ: Files row for ${objectKey} failed: ${row.Error}`);
71
+ }
72
+ return row.ID;
73
+ }
74
+ /**
75
+ * Removes an artifact: its object (through the provider its row names), then its row. A legacy row's local file is
76
+ * removed after the row.
77
+ *
78
+ * @throws Error when the row is not found, the object cannot be removed (the row is kept), or the row cannot be deleted
79
+ */
80
+ async delete(fileId) {
81
+ const file = await this.storage.LoadFileRow(fileId, this.entityFactory);
82
+ if (!file)
83
+ throw new Error(`Predictive Studio model artifacts: artifact file ${fileId} not found`);
84
+ const objectKey = file.ProviderKey;
85
+ if (objectKey && !IsSafeStorageObjectKey(objectKey)) {
86
+ throw new Error(`Predictive Studio model artifacts: artifact file ${fileId} has an unsafe storage key "${objectKey}"`);
87
+ }
88
+ if (objectKey)
89
+ await this.deleteObject(file.ProviderID, objectKey);
90
+ if (!(await file.Delete())) {
91
+ throw new Error(`Predictive Studio model artifacts: deleting artifact file ${fileId} failed: ${file.LatestResult?.CompleteMessage || 'unknown error'}`);
92
+ }
93
+ if (!objectKey)
94
+ await rm(LocalArtifactPath(ResolveLocalArtifactBaseDir(), fileId), { force: true });
95
+ }
96
+ async deleteObject(providerId, objectKey) {
97
+ const { Driver, Provider } = await this.storage.DriverFor(providerId);
98
+ if (!(await Driver.DeleteObject(objectKey))) {
99
+ throw new Error(`Predictive Studio model artifacts: storage provider "${Provider.Name}" could not delete ${objectKey}`);
100
+ }
101
+ }
102
+ /** `<KEY_PREFIX>/<fresh UUID>/<name>`; refuses a name that is not one safe key segment. */
103
+ static objectKeyFor(name) {
104
+ const objectKey = `${StorageProviderArtifactStore.KEY_PREFIX}/${randomUUID()}/${name}`;
105
+ if (name.trim().length === 0 || name.includes('/') || !IsSafeStorageObjectKey(objectKey)) {
106
+ throw new Error(`Predictive Studio model artifacts: "${name}" is not a safe artifact name`);
107
+ }
108
+ return objectKey;
109
+ }
110
+ /** Why the probe could not be written, or null when it was. */
111
+ static async probeWriteFailure(binding, probeKey) {
112
+ try {
113
+ const written = await binding.Driver.PutObject(probeKey, Buffer.from('predictive-studio write probe'), 'text/plain');
114
+ return written ? null : 'the provider refused the object';
115
+ }
116
+ catch (error) {
117
+ return error instanceof Error ? error.message : String(error);
118
+ }
119
+ }
120
+ /** Deletes the write probe; a failure is logged as a warning, since the write it proved succeeded. */
121
+ static async removeProbe(binding, probeKey) {
122
+ let reason;
123
+ try {
124
+ reason = (await binding.Driver.DeleteObject(probeKey)) ? null : 'the provider refused the delete';
125
+ }
126
+ catch (error) {
127
+ reason = error instanceof Error ? error.message : String(error);
128
+ }
129
+ if (reason !== null) {
130
+ LogWarning(`Predictive Studio storage: could not delete the write probe ${probeKey} from "${binding.Provider.Name}" (${reason}); the provider can write, so the run goes ahead, but deletes (rollbacks) through it may fail too`);
131
+ }
132
+ }
133
+ /** Removes an object whose row could not be saved; a failure is logged, since the row's error is the one thrown. */
134
+ static async removeUnrecordedObject(binding, objectKey) {
135
+ let reason;
136
+ try {
137
+ reason = (await binding.Driver.DeleteObject(objectKey)) ? null : 'the provider refused the delete';
138
+ }
139
+ catch (error) {
140
+ reason = error instanceof Error ? error.message : String(error);
141
+ }
142
+ if (reason !== null) {
143
+ LogError(`Predictive Studio model artifacts: could not delete ${objectKey} from "${binding.Provider.Name}" after its MJ: Files row failed to save (${reason})`);
144
+ }
145
+ }
146
+ }
147
+ //# sourceMappingURL=storage-provider-artifact-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-provider-artifact-store.js","sourceRoot":"","sources":["../../src/training/storage-provider-artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAA6B,MAAM,gCAAgC,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAGlF,sEAAsE;AACtE,MAAM,OAAO,4BAA4B;IACvC,kEAAkE;aAC3C,eAAU,GAAG,mCAAmC,CAAC;IACxE,kFAAkF;aAC1D,eAAU,GAAG,QAAQ,C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C;YACf,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,QAAQ,CAAC,uDAAuD,SAAS,UAAU,OAAO,CAAC,QAAQ,CAAC,IAAI,6CAA6C,MAAM,GAAG,CAAC,CAAC;QAClK,CAAC;IACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { CalibrationHold, TrainingLeakageAudit } from './types.js';
2
+ /** Typed readers of a trainer model's stored Lineage keys. */
3
+ export declare class TrainerModelLineageReader {
4
+ /**
5
+ * The run's leakage audit ({@link TrainerModelLineage.trainingLeakageAudit}): the finalist importance's top feature and
6
+ * its share. Null when the Lineage is absent or unreadable, records no audit, or the audit is not a feature name with
7
+ * a finite share.
8
+ *
9
+ * @param lineage the model's `Lineage` JSON text
10
+ */
11
+ static LeakageAuditOf(lineage: string | null | undefined): TrainingLeakageAudit | null;
12
+ /**
13
+ * The model's calibration hold ({@link TrainerModelLineage.calibrationHold}); null when the Lineage is absent or
14
+ * unreadable or records no hold. A recorded hold whose slope is not a finite number holds with a slope of null (it
15
+ * could not be measured): an unreadable slope never releases the hold.
16
+ *
17
+ * @param lineage the model's `Lineage` JSON text
18
+ */
19
+ static CalibrationHoldOf(lineage: string | null | undefined): CalibrationHold | null;
20
+ /**
21
+ * The driver key of the model's shipped artifact ({@link TrainerModelLineage.shippedDriver}); null when the Lineage is
22
+ * absent or unreadable or names none (a model trained before the trainer recorded it).
23
+ *
24
+ * @param lineage the model's `Lineage` JSON text
25
+ */
26
+ static ShippedDriverOf(lineage: string | null | undefined): string | null;
27
+ /** The Lineage's member `key` when it is a JSON object; null otherwise. */
28
+ private static objectKey;
29
+ /** The Lineage text as a JSON object; null when it is absent, does not parse or is not an object. */
30
+ private static lineageObject;
31
+ }
32
+ //# sourceMappingURL=trainer-model-lineage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-model-lineage.d.ts","sourceRoot":"","sources":["../../src/training/trainer-model-lineage.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAuB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1F,8DAA8D;AAC9D,qBAAa,yBAAyB;IACpC;;;;;;OAMG;WACW,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,GAAG,IAAI;IAQ7F;;;;;;OAMG;WACW,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,GAAG,IAAI;IAM3F;;;;;OAKG;WACW,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;IAKhF,2EAA2E;IAC3E,OAAO,CAAC,MAAM,CAAC,SAAS;IAKxB,qGAAqG;IACrG,OAAO,CAAC,MAAM,CAAC,aAAa;CAI7B"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @module training/trainer-model-lineage
3
+ *
4
+ * Reads back the keys a trainer run writes to `MJ: ML Models.Lineage` ({@link TrainerModelLineage}) that decide what
5
+ * may happen to the model after training: its leakage audit, its calibration hold and the driver of its shipped
6
+ * artifact. The promotion gate, scoring readiness and the pipeline builder read them here, so a key is parsed one way.
7
+ * A Lineage that is missing, unreadable or written before a key existed reads as the key's absence (null): such a
8
+ * model behaves as it did before the key was written.
9
+ */
10
+ import { JsonParse } from '@memberjunction/predictive-studio-core';
11
+ /** Typed readers of a trainer model's stored Lineage keys. */
12
+ export class TrainerModelLineageReader {
13
+ /**
14
+ * The run's leakage audit ({@link TrainerModelLineage.trainingLeakageAudit}): the finalist importance's top feature and
15
+ * its share. Null when the Lineage is absent or unreadable, records no audit, or the audit is not a feature name with
16
+ * a finite share.
17
+ *
18
+ * @param lineage the model's `Lineage` JSON text
19
+ */
20
+ static LeakageAuditOf(lineage) {
21
+ const audit = TrainerModelLineageReader.objectKey(lineage, 'trainingLeakageAudit');
22
+ if (audit === null)
23
+ return null;
24
+ const topFeature = JsonParse.JsonString(audit, 'topFeature');
25
+ const topShare = JsonParse.JsonNumber(audit, 'topShare');
26
+ return topFeature === null || topShare === null ? null : { topFeature, topShare };
27
+ }
28
+ /**
29
+ * The model's calibration hold ({@link TrainerModelLineage.calibrationHold}); null when the Lineage is absent or
30
+ * unreadable or records no hold. A recorded hold whose slope is not a finite number holds with a slope of null (it
31
+ * could not be measured): an unreadable slope never releases the hold.
32
+ *
33
+ * @param lineage the model's `Lineage` JSON text
34
+ */
35
+ static CalibrationHoldOf(lineage) {
36
+ const hold = TrainerModelLineageReader.objectKey(lineage, 'calibrationHold');
37
+ if (hold === null)
38
+ return null;
39
+ return { slope: JsonParse.JsonNumber(hold, 'slope') };
40
+ }
41
+ /**
42
+ * The driver key of the model's shipped artifact ({@link TrainerModelLineage.shippedDriver}); null when the Lineage is
43
+ * absent or unreadable or names none (a model trained before the trainer recorded it).
44
+ *
45
+ * @param lineage the model's `Lineage` JSON text
46
+ */
47
+ static ShippedDriverOf(lineage) {
48
+ const parsed = TrainerModelLineageReader.lineageObject(lineage);
49
+ return parsed === null ? null : JsonParse.JsonString(parsed, 'shippedDriver');
50
+ }
51
+ /** The Lineage's member `key` when it is a JSON object; null otherwise. */
52
+ static objectKey(lineage, key) {
53
+ const parsed = TrainerModelLineageReader.lineageObject(lineage);
54
+ return parsed === null ? null : JsonParse.JsonObjectField(parsed, key);
55
+ }
56
+ /** The Lineage text as a JSON object; null when it is absent, does not parse or is not an object. */
57
+ static lineageObject(lineage) {
58
+ const parsed = JsonParse.ParseJsonText(lineage, 'Lineage');
59
+ return parsed.Ok && JsonParse.IsJsonObject(parsed.Value) ? parsed.Value : null;
60
+ }
61
+ }
62
+ //# sourceMappingURL=trainer-model-lineage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-model-lineage.js","sourceRoot":"","sources":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,CAAC,SAAS,CAAC,OAAkC,EAAE,GAA8B;QACzF,MAAM,MAAM,GAAG,yBAAyB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,qGAAqG;IAC7F,MAAM,CAAC,aAAa,CAAC,OAAkC;QAC7D,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,EAAE,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACjF,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @module training/trainer-request
3
+ *
4
+ * Builds the trainer request for one run from its Training Snapshot and Evaluation Protocol: the matrix and row
5
+ * manifest as pre-authorised downloads carrying their stored SHA-256 (the sidecar verifies both before parsing), the
6
+ * snapshot's feature-schema hash (copied from the snapshot row, never recomputed), the unit's task, the candidates, the
7
+ * protocol's seed, one thread (so a seeded run is deterministic) and the protocol's compute budget as the timeout. The
8
+ * snapshot's provenance file is not sent: the trainer does not read it.
9
+ */
10
+ import { type CandidateSpec, type EvaluationProtocolSpec, type TaskType, type TrainerRequest, type TrainerRequestConfig } from '@memberjunction/predictive-studio-core';
11
+ import type { MJMLTrainingSnapshotEntity } from '@memberjunction/core-entities';
12
+ import type { ISnapshotFileStore } from '../snapshot/snapshot-file-store.js';
13
+ /** Everything one trainer request is built from. */
14
+ export interface TrainerRequestInput {
15
+ readonly TrainingRunID: string;
16
+ readonly Snapshot: Pick<MJMLTrainingSnapshotEntity, 'ID' | 'ContentHash' | 'FeatureSchemaHash' | 'MatrixFileID' | 'MatrixSha256' | 'RowManifestFileID' | 'RowManifestSha256'>;
17
+ readonly Files: ISnapshotFileStore;
18
+ /** The protocol the run is judged under; whether it fits the unit is checked where training binds the two. */
19
+ readonly Protocol: EvaluationProtocolSpec;
20
+ readonly Task: TaskType;
21
+ readonly Candidates: readonly CandidateSpec[];
22
+ /** The seed; default the protocol's. A retrain replays the logged one. */
23
+ readonly Seed?: number;
24
+ /** The run timeout in seconds; default the protocol's compute budget. A retrain replays the logged one. */
25
+ readonly TimeoutSeconds?: number;
26
+ /** Default 1. */
27
+ readonly Threads?: number;
28
+ /** Default 2. */
29
+ readonly MaxRetries?: number;
30
+ /** The downloads' issue time; default the current time. */
31
+ readonly Now?: Date;
32
+ }
33
+ /** Builds and summarises trainer requests. */
34
+ export declare class TrainerRequestBuilder {
35
+ /** The trainer's default retry bound for a transport failure or a sidecar fault. */
36
+ static readonly DefaultMaxRetries = 2;
37
+ /** The request for one run. */
38
+ static BuildTrainerRequest(i: TrainerRequestInput): Promise<TrainerRequest>;
39
+ /** What a retrain needs to send the request again (the downloads expire, so they are not kept). */
40
+ static TrainerRequestConfigOf(req: TrainerRequest): TrainerRequestConfig;
41
+ /**
42
+ * One candidate from a pipeline's algorithm and its Hyperparameters JSON. Only scalar values cross to the sidecar, so
43
+ * a nested value is refused by name rather than dropped.
44
+ *
45
+ * @throws Error when the JSON does not parse, is not an object, or holds a non-scalar value
46
+ */
47
+ static CandidateFromPipeline(name: string, algorithmId: string, driverKey: string, hyperparametersJson: string | null): CandidateSpec;
48
+ private static isScalar;
49
+ }
50
+ //# sourceMappingURL=trainer-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-request.d.ts","sourceRoot":"","sources":["../../src/training/trainer-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAG3B,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,wCAAwC,CAAC;AAChD,OAAO,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E,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa;IAY5I,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @module training/trainer-request
3
+ *
4
+ * Builds the trainer request for one run from its Training Snapshot and Evaluation Protocol: the matrix and row
5
+ * manifest as pre-authorised downloads carrying their stored SHA-256 (the sidecar verifies both before parsing), the
6
+ * snapshot's feature-schema hash (copied from the snapshot row, never recomputed), the unit's task, the candidates, the
7
+ * protocol's seed, one thread (so a seeded run is deterministic) and the protocol's compute budget as the timeout. The
8
+ * snapshot's provenance file is not sent: the trainer does not read it.
9
+ */
10
+ import { JsonParse, } from '@memberjunction/predictive-studio-core';
11
+ /** Builds and summarises trainer requests. */
12
+ export class TrainerRequestBuilder {
13
+ /** The trainer's default retry bound for a transport failure or a sidecar fault. */
14
+ static { this.DefaultMaxRetries = 2; }
15
+ /** The request for one run. */
16
+ static async BuildTrainerRequest(i) {
17
+ const [matrix, rowManifest] = await Promise.all([
18
+ i.Files.CreatePreAuthDownload(i.Snapshot.MatrixFileID, i.Snapshot.MatrixSha256, i.Now),
19
+ i.Files.CreatePreAuthDownload(i.Snapshot.RowManifestFileID, i.Snapshot.RowManifestSha256, i.Now),
20
+ ]);
21
+ // `??` throughout: 0 is a real seed and a real retry bound, and a retrain replays it.
22
+ return {
23
+ trainingRunId: i.TrainingRunID,
24
+ snapshot: { id: i.Snapshot.ID, contentHash: i.Snapshot.ContentHash, featureSchemaHash: i.Snapshot.FeatureSchemaHash, matrix, rowManifest },
25
+ incumbent: null,
26
+ protocol: i.Protocol,
27
+ task: i.Task,
28
+ candidates: i.Candidates,
29
+ // `??`, not `||`: seed 0 and zero retries are real settings, and a 0 thread count or timeout must reach the
30
+ // sidecar's own validation (which refuses it) instead of being silently replaced by the default.
31
+ seed: i.Seed ?? i.Protocol.seed,
32
+ threads: i.Threads ?? 1,
33
+ timeoutSeconds: i.TimeoutSeconds ?? i.Protocol.budgets.maxComputeSeconds,
34
+ maxRetries: i.MaxRetries ?? TrainerRequestBuilder.DefaultMaxRetries,
35
+ };
36
+ }
37
+ /** What a retrain needs to send the request again (the downloads expire, so they are not kept). */
38
+ static TrainerRequestConfigOf(req) {
39
+ return { evaluationProtocolId: req.protocol.id, candidates: req.candidates, seed: req.seed, threads: req.threads, timeoutSeconds: req.timeoutSeconds, maxRetries: req.maxRetries };
40
+ }
41
+ /**
42
+ * One candidate from a pipeline's algorithm and its Hyperparameters JSON. Only scalar values cross to the sidecar, so
43
+ * a nested value is refused by name rather than dropped.
44
+ *
45
+ * @throws Error when the JSON does not parse, is not an object, or holds a non-scalar value
46
+ */
47
+ static CandidateFromPipeline(name, algorithmId, driverKey, hyperparametersJson) {
48
+ const parsed = JsonParse.ParseJsonText(hyperparametersJson || '{}', 'Hyperparameters');
49
+ if (parsed.Ok === false)
50
+ throw new Error(parsed.Errors.join('; '));
51
+ if (!JsonParse.IsJsonObject(parsed.Value))
52
+ throw new Error('Hyperparameters must be a JSON object');
53
+ const hyperparameters = {};
54
+ for (const [key, value] of Object.entries(parsed.Value)) {
55
+ if (!TrainerRequestBuilder.isScalar(value))
56
+ throw new Error(`hyperparameter '${key}' must be a number, string, boolean or null`);
57
+ hyperparameters[key] = value;
58
+ }
59
+ return { name, algorithmId, driverKey, hyperparameters };
60
+ }
61
+ static isScalar(value) {
62
+ return value === null || typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean';
63
+ }
64
+ }
65
+ //# sourceMappingURL=trainer-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-request.js","sourceRoot":"","sources":["../../src/training/trainer-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,SAAS,GAQV,MAAM,wCAAwC,CAAC;AA4BhD,8CAA8C;AAC9C,MAAM,OAAO,qBAAqB;IAChC,oFAAoF;aAC7D,sBAAiB,GAAG,CAAC,CAAC;IAE7C,+BAA+B;IACxB,MAAM,CAAC,KAA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AI,OAAO,KAAK,KAAK,SAAS,CAAC;IAChH,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @module training/trainer-result
3
+ *
4
+ * Records a trainer's {@link TrainerResult} on its `MJ: ML Training Runs` row. Real compute is recorded on every
5
+ * outcome (`ComputeSeconds` is the trainer's `computeSeconds`; `ComputeCost` prices it); a failed result records its
6
+ * stage and message and no metrics; a completed result whose `CodeVersion` lacks a required library version or
7
+ * the thread count is refused as a lineage gap: such a run cannot be reproduced, so it is not marked Completed. The
8
+ * gate decision is not recorded here: the gate record stores the decision computed in TypeScript.
9
+ */
10
+ import type { MJMLTrainingRunEntity } from '@memberjunction/core-entities';
11
+ import { type TrainerResult } from '@memberjunction/predictive-studio-core';
12
+ /** The run fields the trainer result writes. */
13
+ export type TrainerRunTarget = Pick<MJMLTrainingRunEntity, 'Status' | 'CompletedAt' | 'ComputeSeconds' | 'ComputeCost' | 'Notes' | 'CodeVersion'>;
14
+ /** Thrown when a completed result's lineage is incomplete; the run is left Failed with the gaps in its notes. */
15
+ export declare class TrainerLineageRefusedError extends Error {
16
+ readonly Gaps: readonly string[];
17
+ constructor(gaps: readonly string[]);
18
+ }
19
+ /** Records a trainer result on its run row. */
20
+ export declare class TrainerRunRecorder {
21
+ /**
22
+ * Writes status, completion time, compute seconds and cost, code version and notes. Does not save: the caller saves
23
+ * the run (and checks `Save()`'s result) in the same flow that registers the artifacts.
24
+ *
25
+ * @throws TrainerLineageRefusedError when a completed result's `CodeVersion` has lineage gaps (the run is
26
+ * marked Failed first, with its compute recorded)
27
+ */
28
+ static ApplyTrainerResultToRun(run: TrainerRunTarget, result: TrainerResult, usdPerSecond: number | null): void;
29
+ }
30
+ //# sourceMappingURL=trainer-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-result.d.ts","sourceRoot":"","sources":["../../src/training/trainer-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAG7F,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,EAAE,QAAQ,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,GAAG,OAAO,GAAG,aAAa,CAAC,CAAC;AAElJ,iHAAiH;AACjH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAgB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;gBAC5B,IAAI,EAAE,SAAS,MAAM,EAAE;CAKpC;AAED,+CAA+C;AAC/C,qBAAa,kBAAkB;IAC7B;;;;;;OAMG;WACW,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;CAmBvH"}
@@ -0,0 +1,40 @@
1
+ import { TrainerContract } from '@memberjunction/predictive-studio-core';
2
+ import { ComputePricing } from './compute-cost.js';
3
+ /** Thrown when a completed result's lineage is incomplete; the run is left Failed with the gaps in its notes. */
4
+ export class TrainerLineageRefusedError extends Error {
5
+ constructor(gaps) {
6
+ super(`Trainer result refused: its CodeVersion lacks ${gaps.join(', ')}`);
7
+ this.name = 'TrainerLineageRefusedError';
8
+ this.Gaps = gaps;
9
+ }
10
+ }
11
+ /** Records a trainer result on its run row. */
12
+ export class TrainerRunRecorder {
13
+ /**
14
+ * Writes status, completion time, compute seconds and cost, code version and notes. Does not save: the caller saves
15
+ * the run (and checks `Save()`'s result) in the same flow that registers the artifacts.
16
+ *
17
+ * @throws TrainerLineageRefusedError when a completed result's `CodeVersion` has lineage gaps (the run is
18
+ * marked Failed first, with its compute recorded)
19
+ */
20
+ static ApplyTrainerResultToRun(run, result, usdPerSecond) {
21
+ run.ComputeSeconds = ComputePricing.RoundSeconds(result.computeSeconds);
22
+ run.ComputeCost = ComputePricing.ComputeCostFor(result.computeSeconds, usdPerSecond);
23
+ run.CompletedAt = new Date();
24
+ if (result.status === 'failed') {
25
+ run.Status = 'Failed';
26
+ run.Notes = `Trainer failed at stage '${result.stage}': ${result.message}`;
27
+ return;
28
+ }
29
+ const gaps = TrainerContract.CodeVersionGaps(result.codeVersion);
30
+ if (gaps.length > 0) {
31
+ run.Status = 'Failed';
32
+ run.Notes = `Trainer result refused: CodeVersion lacks ${gaps.join(', ')}`;
33
+ throw new TrainerLineageRefusedError(gaps);
34
+ }
35
+ run.CodeVersion = JSON.stringify(result.codeVersion);
36
+ run.Status = 'Completed';
37
+ run.Notes = `Trainer completed: finalist '${result.finalist}'.`;
38
+ }
39
+ }
40
+ //# sourceMappingURL=trainer-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trainer-result.js","sourceRoot":"","sources":["../../src/training/trainer-result.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAsB,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKhD,iHAAiH;AACjH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAEnD,YAAY,IAAuB;QACjC,KAAK,CAAC,iDAAiD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,OAAO,kBAAkB;IAC7B;;;;;;OAMG;IACI,MAAM,CAAC,uBAAuB,CAAC,GAAqB,EAAE,MAAqB,EAAE,YAA2B;QAC7G,GAAG,CAAC,cAAc,GAAG,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACxE,GAAG,CAAC,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QACrF,GAAG,CAAC,WAAW,GAAG,I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