@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
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @module scoring/storage-provider-artifact-loader
3
+ *
4
+ * The production {@link IArtifactLoader}: reads a model artifact through the provider its `MJ: Files` row names (never
5
+ * the one `PS_STORAGE_PROVIDER` configures today), so a model trained on one provider still loads after the setting
6
+ * changes. A row with an empty `ProviderKey` was written before model files went through the storage provider; its
7
+ * bytes are read from local disk at `LocalArtifactPath(ResolveLocalArtifactBaseDir(), fileId)` (`PS_ARTIFACT_DIR`).
8
+ */
9
+ import { readFile } from 'node:fs/promises';
10
+ import { IsSafeStorageObjectKey } from '@memberjunction/storage';
11
+ import { PredictiveStudioStorage } from '../storage/ps-storage-provider.js';
12
+ import { LocalArtifactPath, ResolveLocalArtifactBaseDir } from '../training/artifact-store.js';
13
+ /** {@link IArtifactLoader} over the storage providers `MJ: Files` rows name. Stateless: each load reads through its own provider and user. */
14
+ export class StorageProviderArtifactLoader {
15
+ /**
16
+ * The artifact's bytes, or null when there is no such file row or its bytes are gone.
17
+ *
18
+ * @throws Error when the file's key is not safe, or its provider cannot be read on this server
19
+ */
20
+ async load(fileId, contextUser, provider) {
21
+ const storage = new PredictiveStudioStorage(provider, contextUser);
22
+ const location = await storage.LocationOf(fileId);
23
+ if (!location)
24
+ return null;
25
+ if (!location.ProviderKey)
26
+ return StorageProviderArtifactLoader.readLegacy(fileId);
27
+ if (!IsSafeStorageObjectKey(location.ProviderKey)) {
28
+ throw new Error(`Predictive Studio model artifacts: artifact file ${fileId} has an unsafe storage key "${location.ProviderKey}"`);
29
+ }
30
+ const { Driver } = await storage.DriverFor(location.ProviderID);
31
+ if (!(await Driver.ObjectExists(location.ProviderKey)))
32
+ return null;
33
+ return new Uint8Array(await Driver.GetObject({ fullPath: location.ProviderKey }));
34
+ }
35
+ /** A file written before model files went through the storage provider: its local bytes, or null when they are gone. */
36
+ static async readLegacy(fileId) {
37
+ try {
38
+ return new Uint8Array(await readFile(LocalArtifactPath(ResolveLocalArtifactBaseDir(), fileId)));
39
+ }
40
+ catch (error) {
41
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
42
+ return null;
43
+ throw error;
44
+ }
45
+ }
46
+ }
47
+ //# sourceMappingURL=storage-provider-artifact-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-provider-artifact-loader.js","sourceRoot":"","sources":["../../src/scoring/storage-provider-artifact-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAG5F,8IAA8I;AAC9I,MAAM,OAAO,6BAA6B;IACxC;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,WAAqB,EAAE,QAA2B;QAClF,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACnE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,WAAW;YAAE,OAAO,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,oDAAoD,MAAM,+BAA+B,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC;QACpI,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChE,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpE,OAAO,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,wHAAwH;IAChH,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAc;QAC5C,IAAI,CAAC;YACH,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,iBAAiB,CAAC,2BAA2B,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAClG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YACtF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @module scoring/training-keys
3
+ *
4
+ * Which records a model was trained on, for scoring's `inTraining` flag: the development rows of the model's Training
5
+ * Snapshot, read from its verified row manifest.
6
+ */
7
+ import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
8
+ import { type ISnapshotFileStore } from '../snapshot/snapshot-file-store.js';
9
+ /** Training-membership lookups for scoring. */
10
+ export declare class TrainingKeys {
11
+ /**
12
+ * The row ids the model trained on: the development rows of its training run's snapshot manifest (the manifest's
13
+ * SHA-256 verified first). A record whose id is in the set contributed a development row; a record with only
14
+ * locked-holdout rows, or none, did not. Empty for a model whose training run has no snapshot (a model trained
15
+ * without a Prediction Unit).
16
+ *
17
+ * @param files where the manifest file is read; default the storage-provider store on `provider`
18
+ * @throws Error naming the model when a read fails or the snapshot row is missing
19
+ * @throws SnapshotIntegrityError when the stored manifest no longer matches its SHA-256
20
+ */
21
+ static LoadTrainingRowIDs(modelId: string, provider: IMetadataProvider, user: UserInfo | undefined, files?: ISnapshotFileStore): Promise<ReadonlySet<string>>;
22
+ /** The Training Snapshot of the run that produced the model; null when that run has none. */
23
+ private static snapshotIdOf;
24
+ /** The snapshot row's manifest file and hash. */
25
+ private static manifestRefOf;
26
+ }
27
+ //# sourceMappingURL=training-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"training-keys.d.ts","sourceRoot":"","sources":["../../src/scoring/training-keys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAW,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKtF,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG5G,+CAA+C;AAC/C,qBAAa,YAAY;IACvB;;;;;;;;;OASG;WACiB,kBAAkB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,KAAK,GAAE,kBAA0H,GAChI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAO/B,6FAA6F;mBACxE,YAAY;IAQjC,iDAAiD;mBAC5B,aAAa;CASnC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @module scoring/training-keys
3
+ *
4
+ * Which records a model was trained on, for scoring's `inTraining` flag: the development rows of the model's Training
5
+ * Snapshot, read from its verified row manifest.
6
+ */
7
+ import { RunView } from '@memberjunction/core';
8
+ import { EscapeSQLString } from '@memberjunction/global';
9
+ import { HoldoutCarve } from '@memberjunction/predictive-studio-core';
10
+ import { SnapshotManifest } from '../snapshot/snapshot-manifest.js';
11
+ import { StorageProviderSnapshotFileStore } from '../snapshot/snapshot-file-store.js';
12
+ import { MetadataEntityFactory } from '../training/seams.js';
13
+ /** Training-membership lookups for scoring. */
14
+ export class TrainingKeys {
15
+ /**
16
+ * The row ids the model trained on: the development rows of its training run's snapshot manifest (the manifest's
17
+ * SHA-256 verified first). A record whose id is in the set contributed a development row; a record with only
18
+ * locked-holdout rows, or none, did not. Empty for a model whose training run has no snapshot (a model trained
19
+ * without a Prediction Unit).
20
+ *
21
+ * @param files where the manifest file is read; default the storage-provider store on `provider`
22
+ * @throws Error naming the model when a read fails or the snapshot row is missing
23
+ * @throws SnapshotIntegrityError when the stored manifest no longer matches its SHA-256
24
+ */
25
+ static async LoadTrainingRowIDs(modelId, provider, user, files = StorageProviderSnapshotFileStore.ForProviderName(new MetadataEntityFactory(provider), provider, user)) {
26
+ const snapshotId = await TrainingKeys.snapshotIdOf(modelId, provider, user);
27
+ if (snapshotId === null)
28
+ return new Set();
29
+ const snapshot = await TrainingKeys.manifestRefOf(snapshotId, modelId, provider, user);
30
+ return HoldoutCarve.TrainingRowIDs(await SnapshotManifest.ReadSnapshotManifest(snapshot, files));
31
+ }
32
+ /** The Training Snapshot of the run that produced the model; null when that run has none. */
33
+ static async snapshotIdOf(modelId, provider, user) {
34
+ const runs = await RunView.FromMetadataProvider(provider).RunView({
35
+ EntityName: 'MJ: ML Training Runs', ExtraFilter: `ResultingModelID='${EscapeSQLString(modelId)}'`, Fields: ['TrainingSnapshotID'], MaxRows: 1, ResultType: 'simple',
36
+ }, user);
37
+ if (!runs.Success)
38
+ throw new Error(`Loading the training run of model ${modelId} failed: ${runs.ErrorMessage || 'unknown error'}`);
39
+ return runs.Results[0]?.TrainingSnapshotID || null;
40
+ }
41
+ /** The snapshot row's manifest file and hash. */
42
+ static async manifestRefOf(snapshotId, modelId, provider, user) {
43
+ const snaps = await RunView.FromMetadataProvider(provider).RunView({
44
+ EntityName: 'MJ: ML Training Snapshots', ExtraFilter: `ID='${EscapeSQLString(snapshotId)}'`, Fields: ['RowManifestFileID', 'RowManifestSha256'], MaxRows: 1, ResultType: 'simple',
45
+ }, user);
46
+ if (!snaps.Success)
47
+ throw new Error(`Loading Training Snapshot ${snapshotId} of model ${modelId} failed: ${snaps.ErrorMessage || 'unknown error'}`);
48
+ const snapshot = snaps.Results[0];
49
+ if (!snapshot)
50
+ throw new Error(`Training Snapshot ${snapshotId} of model ${modelId} was not found`);
51
+ return snapshot;
52
+ }
53
+ }
54
+ //# sourceMappingURL=training-keys.js.map
@@ -0,0 +1 @@
1
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the
22
22
  * sidecar's `/predict`, which only *applies* it. This is what keeps train-time
23
23
  * and score-time features identical.
24
+ *
25
+ * A model trained on a Prediction Unit goes further: its Lineage stores the unit, the typed feature columns and the
26
+ * kept categorical levels, and scoring assembles the scoped rows as of their decision dates through the same
27
+ * `AsOfFeatureAssembler` training used ({@link LoadedModel.unit}).
24
28
  */
25
29
  import type { UserInfo, IMetadataProvider } from '@memberjunction/core';
26
- import type { MJMLModelEntity } from '@memberjunction/core-entities';
27
- import type { PredictRequest, PredictResponse, FeatureSchemaEntry, FittedPreprocessing, SourceBinding, AsOfStrategy, LeakageGuard, ProblemType, FeatureStepGraph, OutcomeConfig } from '@memberjunction/predictive-studio-core';
30
+ import type { UUIDSet } from '@memberjunction/global';
31
+ import type { MJMLModelEntity, MJRecordProcessEntity_IRecordProcessChallengerConfig } from '@memberjunction/core-entities';
32
+ import type { PredictRequest, PredictResponse, FeatureSchemaEntry, FittedPreprocessing, SourceBinding, AsOfStrategy, LeakageGuard, ProblemType, FeatureStepGraph, OutcomeConfig, FeatureColumnSpec, PredictionUnitSpec } from '@memberjunction/predictive-studio-core';
33
+ import type { ICountingDataAccess } from '../feature-assembly/data-access.js';
34
+ import type { IAssemblyMetadata } from '../feature-assembly/assembly-metadata.js';
35
+ import type { IRecordHistoryReader } from '../feature-assembly/as-of/record-history.js';
36
+ import type { IPredictionUnitStore } from '../prediction-unit/unit-store.js';
28
37
  import type { DatedSourceSpec } from '../feature-assembly/index.js';
38
+ import type { ShadowScoringCoordinator } from './shadow-scoring.js';
29
39
  /**
30
40
  * Read seam for loading the immutable `MJ: ML Models` row to score against.
31
41
  * Wraps `RunView` in production; tests inject a canned entity. Returns `null`
@@ -43,18 +53,20 @@ export interface IMLModelLoader {
43
53
  }
44
54
  /**
45
55
  * Read seam for fetching the serialized model artifact bytes by file id (the
46
- * read-side counterpart to the training `IArtifactStore.save`). Wraps `MJ: Files`
47
- * / MJStorage in production; tests inject an in-memory map.
56
+ * read-side counterpart to the training `IArtifactStore.save`). Reads through the
57
+ * storage provider the file's `MJ: Files` row names in production
58
+ * (`StorageProviderArtifactLoader`); tests inject an in-memory map.
48
59
  */
49
60
  export interface IArtifactLoader {
50
61
  /**
51
62
  * Fetch the serialized artifact bytes previously stored under `fileId`.
52
63
  *
53
64
  * @param fileId the `MLModel.ArtifactFileID` value
54
- * @param contextUser request user — required server-side for isolation/audit
65
+ * @param contextUser the acting user the file row is read as (required: a call site without one is a compile error)
66
+ * @param provider the provider the file row is read through (required: no fallback to the global provider)
55
67
  * @returns the artifact bytes, or `null` when not found
56
68
  */
57
- load(fileId: string, contextUser?: UserInfo): Promise<Uint8Array | null>;
69
+ load(fileId: string, contextUser: UserInfo, provider: IMetadataProvider): Promise<Uint8Array | null>;
58
70
  }
59
71
  /**
60
72
  * Sidecar seam — the `/predict` call. Wraps {@link MLSidecar} from
@@ -69,7 +81,23 @@ export interface ISidecarPredictor {
69
81
  *
70
82
  * @param req the predict request (artifact + frozen preprocessing + schema + rows)
71
83
  */
72
- predict(req: PredictRequest): Promise<PredictResponse>;
84
+ predict(req: PredictRequest, signal?: AbortSignal): Promise<PredictResponse>;
85
+ }
86
+ /**
87
+ * Which Prediction Unit a model's pipeline points at. Scoring asks before reading a model's Lineage, so a unit model
88
+ * whose Lineage is missing or malformed fails loudly instead of being scored as a legacy model.
89
+ */
90
+ export interface IPipelineUnitLookup {
91
+ /** The pipeline's `PredictionUnitID`, or null for a pipeline without a unit. */
92
+ PredictionUnitIDOf(pipelineId: string, contextUser: UserInfo | undefined, provider: IMetadataProvider): Promise<string | null>;
93
+ }
94
+ /**
95
+ * Which records a model was trained on. Scoring asks once per loaded model, so each result can say whether its record
96
+ * contributed a development row to the model's Training Snapshot.
97
+ */
98
+ export interface ITrainingRowsLookup {
99
+ /** The row ids of the model's snapshot manifest whose role is `development`; empty for a model without a snapshot. */
100
+ TrainingRowIDsOf(modelId: string, contextUser: UserInfo | undefined, provider: IMetadataProvider): Promise<ReadonlySet<string>>;
73
101
  }
74
102
  /**
75
103
  * The frozen inference contract resolved off a loaded `MJ: ML Models` row — the
@@ -101,6 +129,25 @@ export interface LoadedModel {
101
129
  leakageGuard: LeakageGuard;
102
130
  /** Metadata-driven outcome and band configuration frozen on the model or resolved from defaults. */
103
131
  outcomeConfig: OutcomeConfig;
132
+ /**
133
+ * For a model trained on a Prediction Unit: the unit version, the typed feature columns and the kept categorical
134
+ * levels its Lineage stored, and the unit's row entity. Null for a model trained without a unit (the legacy path).
135
+ */
136
+ unit: LoadedUnitModel | null;
137
+ /**
138
+ * The records that contributed a development row to the model's Training Snapshot (its manifest's development row
139
+ * ids, compared as UUIDs); empty for a model trained without a snapshot.
140
+ */
141
+ trainingRowIds: UUIDSet;
142
+ }
143
+ /** What scoring needs to assemble a unit model's features exactly as training did. */
144
+ export interface LoadedUnitModel {
145
+ readonly Spec: PredictionUnitSpec;
146
+ readonly Features: readonly FeatureColumnSpec[];
147
+ /** The name of the entity whose records the unit rows are; a scoring scope must hold this entity's records. */
148
+ readonly RowEntity: string;
149
+ /** The kept levels of each categorical column, by column name, as training stored them. */
150
+ readonly CategoryLevels: ReadonlyMap<string, readonly string[]>;
104
151
  }
105
152
  /**
106
153
  * The injected dependency bundle for {@link MLModelInferenceProcessor}. Bundling
@@ -114,6 +161,18 @@ export interface MLInferenceDeps {
114
161
  artifactLoader: IArtifactLoader;
115
162
  /** Sidecar `/predict` seam. */
116
163
  sidecar: ISidecarPredictor;
164
+ /** Which unit a model's pipeline points at; defaults to a `RunViewPipelineUnitLookup` on the run's provider. */
165
+ pipelineUnits?: IPipelineUnitLookup;
166
+ /** Which records a model was trained on; defaults to a `RunViewTrainingRowsLookup` (the snapshot manifest) on the run's provider. */
167
+ trainingRows?: ITrainingRowsLookup;
168
+ /** Prediction Unit store a unit model's unit is loaded from; defaults to a `RunViewPredictionUnitStore` on the run's provider. */
169
+ predictionUnits?: IPredictionUnitStore;
170
+ /** Entity metadata a unit model's assembly resolves against; defaults to a `ProviderAssemblyMetadata` on the run's provider. */
171
+ assemblyMetadata?: IAssemblyMetadata;
172
+ /** The counting data access a unit model's rows are read through; defaults to a `RunViewDataAccess` on the run's provider. */
173
+ dataAccess?: ICountingDataAccess;
174
+ /** The Record Changes history a unit model's assembly replays; defaults to a complete-read `RunViewRecordHistoryReader` over `dataAccess`. */
175
+ history?: IRecordHistoryReader;
117
176
  }
118
177
  /**
119
178
  * Construction options for {@link MLModelInferenceProcessor}.
@@ -140,6 +199,12 @@ export interface MLModelInferenceProcessorOptions {
140
199
  autoTrain?: MLAutoTrainConfig;
141
200
  /** The trainer that fulfils {@link autoTrain}. Required for auto-train to take effect. */
142
201
  autoTrainer?: IModelAutoTrainer;
202
+ /** Optional RecordProcessID associated with this scoring processor instance. */
203
+ recordProcessId?: string;
204
+ /** Optional WS-4.4 shadow challenger configuration (`ChallengerConfiguration`). */
205
+ challengerConfig?: MJRecordProcessEntity_IRecordProcessChallengerConfig;
206
+ /** Optional WS-4.4 shadow scoring coordinator. */
207
+ shadowCoordinator?: ShadowScoringCoordinator;
143
208
  }
144
209
  /**
145
210
  * Opt-in **train-if-untrained** declaration carried in an `'ML Model'` Record
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scoring/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,aAAa,EACd,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;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C;IAChC,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,oDAAoD,CAAC;IACxE,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;CAC9C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE;QACR,gGAAgG;QAChG,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,4FAA4F;QAC5F,IAAI,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;KACjC,CAAC;CACH;AAED,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,wFAAwF;IACxF,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpH;AAED,6EAA6E;AAC7E,YAAY,EAAE,WAAW,EAAE,CAAC"}
@@ -21,6 +21,10 @@
21
21
  * preprocessing travels with the model and is passed straight through to the
22
22
  * sidecar's `/predict`, which only *applies* it. This is what keeps train-time
23
23
  * and score-time features identical.
24
+ *
25
+ * A model trained on a Prediction Unit goes further: its Lineage stores the unit, the typed feature columns and the
26
+ * kept categorical levels, and scoring assembles the scoped rows as of their decision dates through the same
27
+ * `AsOfFeatureAssembler` training used ({@link LoadedModel.unit}).
24
28
  */
25
29
  export {};
26
30
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scoring/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scoring/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
@@ -15,8 +15,8 @@ import { BaseSingleton, IShutdownable } from '@memberjunction/global';
15
15
  * `scoring/seams.ts`) defaulted their constructor parameter to `new MLSidecar()`,
16
16
  * and every production call site (`train-model.action.ts`, `run-experiment.deps.ts`,
17
17
  * `score-record-set.runner.ts`, `operations/delegation.ts`) constructed a fresh
18
- * trainer/predictor per action run with no injected sidecar. `MLSidecar.start()`
19
- * spawns a Python child process in managed mode, but nothing ever called `.stop()`
18
+ * trainer/predictor per action run with no injected sidecar. `MLSidecar.Start()`
19
+ * spawns a Python child process in managed mode, but nothing ever called `Stop()`
20
20
  * on it — every "Train Model" / "Score Record Set" run leaked a live Python
21
21
  * subprocess (its own FastAPI server plus xgboost/lightgbm/scikit-learn process
22
22
  * memory) for the life of the host process. Mirrors the singleton pattern already
@@ -15,8 +15,8 @@ import { BaseSingleton, ShutdownRegistry } from '@memberjunction/global';
15
15
  * `scoring/seams.ts`) defaulted their constructor parameter to `new MLSidecar()`,
16
16
  * and every production call site (`train-model.action.ts`, `run-experiment.deps.ts`,
17
17
  * `score-record-set.runner.ts`, `operations/delegation.ts`) constructed a fresh
18
- * trainer/predictor per action run with no injected sidecar. `MLSidecar.start()`
19
- * spawns a Python child process in managed mode, but nothing ever called `.stop()`
18
+ * trainer/predictor per action run with no injected sidecar. `MLSidecar.Start()`
19
+ * spawns a Python child process in managed mode, but nothing ever called `Stop()`
20
20
  * on it — every "Train Model" / "Score Record Set" run leaked a live Python
21
21
  * subprocess (its own FastAPI server plus xgboost/lightgbm/scikit-learn process
22
22
  * memory) for the life of the host process. Mirrors the singleton pattern already
@@ -53,7 +53,7 @@ export class MLSidecarProvider extends BaseSingleton {
53
53
  if (this._sidecar) {
54
54
  const sidecar = this._sidecar;
55
55
  this._sidecar = null;
56
- await sidecar.stop();
56
+ await sidecar.Stop();
57
57
  }
58
58
  }
59
59
  }
@@ -0,0 +1,16 @@
1
+ /** The assembly code version a Training Snapshot records. */
2
+ export declare class CodeVersionInfo {
3
+ private static packageVersion;
4
+ /**
5
+ * `@memberjunction/predictive-studio@<package version>+<git sha>`. The git SHA comes from `PS_GIT_SHA`, set by the
6
+ * deployment (the sidecar's code version reads the same variable); `||` is deliberate, so an unset or empty
7
+ * `PS_GIT_SHA` both read as `unrecorded`.
8
+ */
9
+ static AssemblyCodeVersion(): string;
10
+ /**
11
+ * This package's version, read once from its own `package.json` (`dist/snapshot` and `src/snapshot` both sit two
12
+ * levels below it). A package.json without a string `version` is a broken install, so it throws.
13
+ */
14
+ private static readPackageVersion;
15
+ }
16
+ //# sourceMappingURL=code-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-version.d.ts","sourceRoot":"","sources":["../../src/snapshot/code-version.ts"],"names":[],"mappings":"AASA,6DAA6D;AAC7D,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,cAAc,CAAuB;IAEpD;;;;OAIG;WACW,mBAAmB,IAAI,MAAM;IAK3C;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAUlC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module snapshot/code-version
3
+ *
4
+ * The code-version stamp a Training Snapshot records: which assembly code built it.
5
+ */
6
+ import { readFileSync } from 'node:fs';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { JsonParse } from '@memberjunction/predictive-studio-core';
9
+ /** The assembly code version a Training Snapshot records. */
10
+ export class CodeVersionInfo {
11
+ static { this.packageVersion = null; }
12
+ /**
13
+ * `@memberjunction/predictive-studio@<package version>+<git sha>`. The git SHA comes from `PS_GIT_SHA`, set by the
14
+ * deployment (the sidecar's code version reads the same variable); `||` is deliberate, so an unset or empty
15
+ * `PS_GIT_SHA` both read as `unrecorded`.
16
+ */
17
+ static AssemblyCodeVersion() {
18
+ const gitSha = process.env.PS_GIT_SHA || 'unrecorded';
19
+ return `@memberjunction/predictive-studio@${CodeVersionInfo.readPackageVersion()}+${gitSha}`;
20
+ }
21
+ /**
22
+ * This package's version, read once from its own `package.json` (`dist/snapshot` and `src/snapshot` both sit two
23
+ * levels below it). A package.json without a string `version` is a broken install, so it throws.
24
+ */
25
+ static readPackageVersion() {
26
+ if (CodeVersionInfo.packageVersion !== null)
27
+ return CodeVersionInfo.packageVersion;
28
+ const path = fileURLToPath(new URL('../../package.json', import.meta.url));
29
+ const json = JsonParse.ParseJsonText(readFileSync(path, 'utf8'), path);
30
+ if (json.Ok === false)
31
+ throw new Error(json.Errors.join('; '));
32
+ const version = JsonParse.IsJsonObject(json.Value) ? JsonParse.JsonString(json.Value, 'version') : null;
33
+ if (version === null)
34
+ throw new Error(`${path} has no string "version"`);
35
+ CodeVersionInfo.packageVersion = version;
36
+ return version;
37
+ }
38
+ }
39
+ //# sourceMappingURL=code-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-version.js","sourceRoot":"","sources":["../../src/snapshot/code-version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,6DAA6D;AAC7D,MAAM,OAAO,eAAe;aACX,mBAAc,GAAkB,IAAI,CAAC;IAEpD;;;;OAIG;IACI,MAAM,CAAC,mBAAmB;QAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,YAAY,CAAC;QACtD,OAAO,qCAAqC,eAAe,CAAC,kBAAkB,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/F,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,kBAAkB;QAC/B,IAAI,eAAe,CAAC,cAAc,KAAK,IAAI;YAAE,OAAO,eAAe,CAAC,cAAc,CAAC;QACnF,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;QACvE,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxG,IAAI,OAAO,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;QACzE,eAAe,CAAC,cAAc,GAAG,OAAO,CAAC;QACzC,OAAO,OAAO,CAAC;IACjB,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @module snapshot/holdout-carver
3
+ *
4
+ * Assigns each row its manifest role: training carves the unit rows before anything is validated or assembled, and
5
+ * carves the assembled rows again before the snapshot is written; the roles are part of the manifest,
6
+ * so they are part of the snapshot's fingerprint. The locked holdout is the one the bound Evaluation Protocol declares
7
+ * ({@link HoldoutCarvers.CarverForProtocol}, the one place a holdout kind maps to a carver): a date carve on the
8
+ * declared column, a seeded row-hash carve, or a forecast's rolling-origin test periods. Each carve returns the roles
9
+ * and what it carved ({@link HoldoutCarveOutcome}); the run stores that summary with its results.
10
+ */
11
+ import { type DecisionSpec, type EvaluationProtocolSpec, type HoldoutCarveSummary, type HoldoutSplit, type PredictionUnitSpec, type SnapshotRowRole } from '@memberjunction/predictive-studio-core';
12
+ import type { AssembledRow } from '../feature-assembly/as-of/as-of-assembler.js';
13
+ import type { UnitRow } from '../prediction-unit/unit-row-reader.js';
14
+ type DateCarved = Extract<HoldoutSplit, {
15
+ readonly kind: 'date-carved';
16
+ }>;
17
+ type RollingOrigin = Extract<HoldoutSplit, {
18
+ readonly kind: 'rolling-origin';
19
+ }>;
20
+ /** A carve: the roles of the rows kept in the snapshot, by row id, and the summary the run stores. */
21
+ export interface HoldoutCarveOutcome {
22
+ /** A row absent from the map is left out of the snapshot (a date carve's rows on or after `holdoutEnd`); the summary counts it. */
23
+ readonly Roles: ReadonlyMap<string, SnapshotRowRole>;
24
+ /** What the run stores as `ValidationResults.carve`. */
25
+ readonly Summary: HoldoutCarveSummary;
26
+ }
27
+ /** A row a carve assigns a role to: only its id is read; everything else comes from its unit row. */
28
+ export type CarvedRowRef = Pick<AssembledRow, 'RowID'>;
29
+ /**
30
+ * Assigns rows their manifest roles and records what it carved. The carve reads only the unit rows' dates, keys and
31
+ * labels and the protocol, never the order the rows arrive in.
32
+ */
33
+ export interface IHoldoutCarver {
34
+ /**
35
+ * The roles of the rows kept in the snapshot and the carve's summary.
36
+ *
37
+ * @param rows the rows to carve (unit rows before assembly, or the assembled rows)
38
+ * @param unitRows the unit row behind each assembled row, by row id
39
+ * @throws TrainingRefusedError (`carve` stage) when the holdout cannot be carved
40
+ */
41
+ AssignRoles(rows: readonly CarvedRowRef[], unitRows: ReadonlyMap<string, UnitRow>): HoldoutCarveOutcome;
42
+ }
43
+ /**
44
+ * The date carve: rows whose carve date is on or after the cutoff (and before `holdoutEnd`, when set) are the locked
45
+ * holdout, earlier rows are development, later rows are left out of the snapshot and counted. The carve date is the
46
+ * unit row's decision date when the protocol's `dateColumn` is `DecisionDate`, else the row's own field of that name.
47
+ * The carve groups rows by the unit row's group key, so a new-entity report holds out whole groups (the unit's group
48
+ * key value, or the row's entity key when the unit declares none; a protocol whose report names another key is
49
+ * refused before any row is read).
50
+ */
51
+ export declare class DateCarvedCarver implements IHoldoutCarver {
52
+ private readonly holdout;
53
+ private readonly period;
54
+ /**
55
+ * @param holdout the protocol's date-carved holdout
56
+ * @param period the unit's decision period, the slice each holdout period summarises
57
+ */
58
+ constructor(holdout: DateCarved, period: DecisionSpec['period']);
59
+ /** @throws TrainingRefusedError (`carve` stage) for a row without a readable carve date, or a carve that leaves no development or no holdout row */
60
+ AssignRoles(rows: readonly CarvedRowRef[], unitRows: ReadonlyMap<string, UnitRow>): HoldoutCarveOutcome;
61
+ /**
62
+ * SHA-256 (lower-case hex) of a set of group keys as the new-entity summary stores it: the distinct keys (the unit row's
63
+ * group key, as the carve groups rows), sorted with `OrdinalCompare`, joined with `\n`, UTF-8.
64
+ */
65
+ static GroupKeysSha256(keys: readonly string[]): string;
66
+ /** The unit row as the date carve reads it; a row whose carve column is empty or names no day is refused. */
67
+ private carveRow;
68
+ }
69
+ /**
70
+ * The seeded group-hash carve for units whose rows share one fixed decision date (no date to carve on): a row is held
71
+ * out when the protocol seed's hash of its group key (the entity key when the unit declares no group field) falls
72
+ * below the fraction, so a group is never split across the holdout, whatever the order the rows were read in.
73
+ * A carve that leaves either side empty is refused.
74
+ */
75
+ export declare class SeededRandomCarver implements IHoldoutCarver {
76
+ private readonly fraction;
77
+ private readonly seed;
78
+ /**
79
+ * @param fraction the protocol's holdout fraction, in (0, 1)
80
+ * @param seed the protocol's seed
81
+ */
82
+ constructor(fraction: number, seed: number);
83
+ /** @throws TrainingRefusedError (`carve` stage, `seeded-random-side-empty`) when the carve leaves no holdout or no development row */
84
+ AssignRoles(rows: readonly CarvedRowRef[], unitRows: ReadonlyMap<string, UnitRow>): HoldoutCarveOutcome;
85
+ /** A carve with no holdout row has nothing to test on, and one with no development row nothing to train on. */
86
+ private refuseEmptySide;
87
+ /** Holdout rows per class label; null when no holdout row has a text label (a numeric task). */
88
+ private static classCounts;
89
+ }
90
+ /**
91
+ * Holds out a forecast's rolling-origin test periods: the last `origins × horizonPeriods` distinct periods, the rows the
92
+ * trainer scores its outer origins on (Core's `HoldoutCarve.RollingOriginCarve`, so the manifest's locked-holdout rows
93
+ * are exactly the trainer's design). Each row's period is its unit row's period.
94
+ */
95
+ export declare class RollingOriginCarver implements IHoldoutCarver {
96
+ private readonly holdout;
97
+ /** @param holdout the protocol's rolling-origin holdout */
98
+ constructor(holdout: RollingOrigin);
99
+ /** @throws TrainingRefusedError (`carve` stage) for a row without a period, or a series too short for the design */
100
+ AssignRoles(rows: readonly CarvedRowRef[], unitRows: ReadonlyMap<string, UnitRow>): HoldoutCarveOutcome;
101
+ }
102
+ /** The carver a protocol declares, and the unit-row lookup the carvers share. */
103
+ export declare class HoldoutCarvers {
104
+ /** The carver for the protocol's holdout kind: the only place a holdout kind maps to a carver. */
105
+ static CarverForProtocol(protocol: Pick<EvaluationProtocolSpec, 'holdout' | 'seed'>, unit: Pick<PredictionUnitSpec, 'decision'>): IHoldoutCarver;
106
+ /** The unit row behind an assembled row; an assembled row without one is a caller error (the rows came from elsewhere). */
107
+ static UnitRowOf(unitRows: ReadonlyMap<string, UnitRow>, rowId: string): UnitRow;
108
+ }
109
+ export {};
110
+ //# sourceMappingURL=holdout-carver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holdout-carver.d.ts","sourceRoot":"","sources":["../../src/snapshot/holdout-carver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAIlE,KAAK,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