@memberjunction/predictive-studio 0.0.1 → 5.44.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 (266) hide show
  1. package/README.md +101 -28
  2. package/dist/actions/base-predictive-studio.action.d.ts +63 -0
  3. package/dist/actions/base-predictive-studio.action.d.ts.map +1 -0
  4. package/dist/actions/base-predictive-studio.action.js +125 -0
  5. package/dist/actions/base-predictive-studio.action.js.map +1 -0
  6. package/dist/actions/index.d.ts +38 -0
  7. package/dist/actions/index.d.ts.map +1 -0
  8. package/dist/actions/index.js +49 -0
  9. package/dist/actions/index.js.map +1 -0
  10. package/dist/actions/model-scoring-action-generator.d.ts +108 -0
  11. package/dist/actions/model-scoring-action-generator.d.ts.map +1 -0
  12. package/dist/actions/model-scoring-action-generator.js +316 -0
  13. package/dist/actions/model-scoring-action-generator.js.map +1 -0
  14. package/dist/actions/promote-model.action.d.ts +102 -0
  15. package/dist/actions/promote-model.action.d.ts.map +1 -0
  16. package/dist/actions/promote-model.action.js +132 -0
  17. package/dist/actions/promote-model.action.js.map +1 -0
  18. package/dist/actions/promote-model.gate.d.ts +77 -0
  19. package/dist/actions/promote-model.gate.d.ts.map +1 -0
  20. package/dist/actions/promote-model.gate.js +205 -0
  21. package/dist/actions/promote-model.gate.js.map +1 -0
  22. package/dist/actions/run-experiment.action.d.ts +60 -0
  23. package/dist/actions/run-experiment.action.d.ts.map +1 -0
  24. package/dist/actions/run-experiment.action.js +134 -0
  25. package/dist/actions/run-experiment.action.js.map +1 -0
  26. package/dist/actions/run-experiment.deps.d.ts +47 -0
  27. package/dist/actions/run-experiment.deps.d.ts.map +1 -0
  28. package/dist/actions/run-experiment.deps.js +71 -0
  29. package/dist/actions/run-experiment.deps.js.map +1 -0
  30. package/dist/actions/schedule-model-scoring.action.d.ts +71 -0
  31. package/dist/actions/schedule-model-scoring.action.d.ts.map +1 -0
  32. package/dist/actions/schedule-model-scoring.action.js +148 -0
  33. package/dist/actions/schedule-model-scoring.action.js.map +1 -0
  34. package/dist/actions/score-record-set.action.d.ts +133 -0
  35. package/dist/actions/score-record-set.action.d.ts.map +1 -0
  36. package/dist/actions/score-record-set.action.js +136 -0
  37. package/dist/actions/score-record-set.action.js.map +1 -0
  38. package/dist/actions/score-record-set.runner.d.ts +192 -0
  39. package/dist/actions/score-record-set.runner.d.ts.map +1 -0
  40. package/dist/actions/score-record-set.runner.js +416 -0
  41. package/dist/actions/score-record-set.runner.js.map +1 -0
  42. package/dist/actions/train-model.action.d.ts +57 -0
  43. package/dist/actions/train-model.action.d.ts.map +1 -0
  44. package/dist/actions/train-model.action.js +111 -0
  45. package/dist/actions/train-model.action.js.map +1 -0
  46. package/dist/agent/index.d.ts +14 -0
  47. package/dist/agent/index.d.ts.map +1 -0
  48. package/dist/agent/index.js +14 -0
  49. package/dist/agent/index.js.map +1 -0
  50. package/dist/agent/model-dev-orchestrator-agent.d.ts +42 -0
  51. package/dist/agent/model-dev-orchestrator-agent.d.ts.map +1 -0
  52. package/dist/agent/model-dev-orchestrator-agent.js +76 -0
  53. package/dist/agent/model-dev-orchestrator-agent.js.map +1 -0
  54. package/dist/agent/modeling-plan-to-pipeline.d.ts +49 -0
  55. package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -0
  56. package/dist/agent/modeling-plan-to-pipeline.js +101 -0
  57. package/dist/agent/modeling-plan-to-pipeline.js.map +1 -0
  58. package/dist/agent/pipeline-builder-agent.d.ts +58 -0
  59. package/dist/agent/pipeline-builder-agent.d.ts.map +1 -0
  60. package/dist/agent/pipeline-builder-agent.js +101 -0
  61. package/dist/agent/pipeline-builder-agent.js.map +1 -0
  62. package/dist/agent/pipeline-builder.d.ts +67 -0
  63. package/dist/agent/pipeline-builder.d.ts.map +1 -0
  64. package/dist/agent/pipeline-builder.js +114 -0
  65. package/dist/agent/pipeline-builder.js.map +1 -0
  66. package/dist/experiment/concurrency.d.ts +41 -0
  67. package/dist/experiment/concurrency.d.ts.map +1 -0
  68. package/dist/experiment/concurrency.js +54 -0
  69. package/dist/experiment/concurrency.js.map +1 -0
  70. package/dist/experiment/experiment-orchestrator.d.ts +136 -0
  71. package/dist/experiment/experiment-orchestrator.d.ts.map +1 -0
  72. package/dist/experiment/experiment-orchestrator.js +408 -0
  73. package/dist/experiment/experiment-orchestrator.js.map +1 -0
  74. package/dist/experiment/index.d.ts +17 -0
  75. package/dist/experiment/index.d.ts.map +1 -0
  76. package/dist/experiment/index.js +17 -0
  77. package/dist/experiment/index.js.map +1 -0
  78. package/dist/experiment/leaderboard.d.ts +50 -0
  79. package/dist/experiment/leaderboard.d.ts.map +1 -0
  80. package/dist/experiment/leaderboard.js +91 -0
  81. package/dist/experiment/leaderboard.js.map +1 -0
  82. package/dist/experiment/seams.d.ts +95 -0
  83. package/dist/experiment/seams.d.ts.map +1 -0
  84. package/dist/experiment/seams.js +126 -0
  85. package/dist/experiment/seams.js.map +1 -0
  86. package/dist/experiment/types.d.ts +228 -0
  87. package/dist/experiment/types.d.ts.map +1 -0
  88. package/dist/experiment/types.js +19 -0
  89. package/dist/experiment/types.js.map +1 -0
  90. package/dist/experiment/wave-strategist.d.ts +31 -0
  91. package/dist/experiment/wave-strategist.d.ts.map +1 -0
  92. package/dist/experiment/wave-strategist.js +50 -0
  93. package/dist/experiment/wave-strategist.js.map +1 -0
  94. package/dist/feature-assembly/as-of.d.ts +74 -0
  95. package/dist/feature-assembly/as-of.d.ts.map +1 -0
  96. package/dist/feature-assembly/as-of.js +136 -0
  97. package/dist/feature-assembly/as-of.js.map +1 -0
  98. package/dist/feature-assembly/data-access.d.ts +114 -0
  99. package/dist/feature-assembly/data-access.d.ts.map +1 -0
  100. package/dist/feature-assembly/data-access.js +68 -0
  101. package/dist/feature-assembly/data-access.js.map +1 -0
  102. package/dist/feature-assembly/feature-assembly-executor.d.ts +273 -0
  103. package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -0
  104. package/dist/feature-assembly/feature-assembly-executor.js +521 -0
  105. package/dist/feature-assembly/feature-assembly-executor.js.map +1 -0
  106. package/dist/feature-assembly/index.d.ts +13 -0
  107. package/dist/feature-assembly/index.d.ts.map +1 -0
  108. package/dist/feature-assembly/index.js +13 -0
  109. package/dist/feature-assembly/index.js.map +1 -0
  110. package/dist/feature-assembly/leakage-guard.d.ts +86 -0
  111. package/dist/feature-assembly/leakage-guard.d.ts.map +1 -0
  112. package/dist/feature-assembly/leakage-guard.js +111 -0
  113. package/dist/feature-assembly/leakage-guard.js.map +1 -0
  114. package/dist/feature-assembly/vision-llm.d.ts +125 -0
  115. package/dist/feature-assembly/vision-llm.d.ts.map +1 -0
  116. package/dist/feature-assembly/vision-llm.js +211 -0
  117. package/dist/feature-assembly/vision-llm.js.map +1 -0
  118. package/dist/feature-pipelines/feature-pipeline-engine.d.ts +159 -0
  119. package/dist/feature-pipelines/feature-pipeline-engine.d.ts.map +1 -0
  120. package/dist/feature-pipelines/feature-pipeline-engine.js +298 -0
  121. package/dist/feature-pipelines/feature-pipeline-engine.js.map +1 -0
  122. package/dist/feature-pipelines/index.d.ts +13 -0
  123. package/dist/feature-pipelines/index.d.ts.map +1 -0
  124. package/dist/feature-pipelines/index.js +13 -0
  125. package/dist/feature-pipelines/index.js.map +1 -0
  126. package/dist/feature-pipelines/types.d.ts +72 -0
  127. package/dist/feature-pipelines/types.d.ts.map +1 -0
  128. package/dist/feature-pipelines/types.js +17 -0
  129. package/dist/feature-pipelines/types.js.map +1 -0
  130. package/dist/index.d.ts +37 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +80 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/maintenance/index.d.ts +19 -0
  135. package/dist/maintenance/index.d.ts.map +1 -0
  136. package/dist/maintenance/index.js +19 -0
  137. package/dist/maintenance/index.js.map +1 -0
  138. package/dist/maintenance/maintenance-engine.d.ts +152 -0
  139. package/dist/maintenance/maintenance-engine.d.ts.map +1 -0
  140. package/dist/maintenance/maintenance-engine.js +412 -0
  141. package/dist/maintenance/maintenance-engine.js.map +1 -0
  142. package/dist/maintenance/metrics.d.ts +37 -0
  143. package/dist/maintenance/metrics.d.ts.map +1 -0
  144. package/dist/maintenance/metrics.js +85 -0
  145. package/dist/maintenance/metrics.js.map +1 -0
  146. package/dist/maintenance/seams.d.ts +85 -0
  147. package/dist/maintenance/seams.d.ts.map +1 -0
  148. package/dist/maintenance/seams.js +166 -0
  149. package/dist/maintenance/seams.js.map +1 -0
  150. package/dist/maintenance/types.d.ts +318 -0
  151. package/dist/maintenance/types.d.ts.map +1 -0
  152. package/dist/maintenance/types.js +27 -0
  153. package/dist/maintenance/types.js.map +1 -0
  154. package/dist/operations/__tests__/helpers.d.ts +30 -0
  155. package/dist/operations/__tests__/helpers.d.ts.map +1 -0
  156. package/dist/operations/__tests__/helpers.js +44 -0
  157. package/dist/operations/__tests__/helpers.js.map +1 -0
  158. package/dist/operations/control-experiment-session.operation.d.ts +33 -0
  159. package/dist/operations/control-experiment-session.operation.d.ts.map +1 -0
  160. package/dist/operations/control-experiment-session.operation.js +71 -0
  161. package/dist/operations/control-experiment-session.operation.js.map +1 -0
  162. package/dist/operations/create-scoring-process.operation.d.ts +30 -0
  163. package/dist/operations/create-scoring-process.operation.d.ts.map +1 -0
  164. package/dist/operations/create-scoring-process.operation.js +65 -0
  165. package/dist/operations/create-scoring-process.operation.js.map +1 -0
  166. package/dist/operations/delegation.d.ts +113 -0
  167. package/dist/operations/delegation.d.ts.map +1 -0
  168. package/dist/operations/delegation.js +139 -0
  169. package/dist/operations/delegation.js.map +1 -0
  170. package/dist/operations/index.d.ts +40 -0
  171. package/dist/operations/index.d.ts.map +1 -0
  172. package/dist/operations/index.js +55 -0
  173. package/dist/operations/index.js.map +1 -0
  174. package/dist/operations/promote-model.operation.d.ts +57 -0
  175. package/dist/operations/promote-model.operation.d.ts.map +1 -0
  176. package/dist/operations/promote-model.operation.js +113 -0
  177. package/dist/operations/promote-model.operation.js.map +1 -0
  178. package/dist/operations/run-feature-pipeline.operation.d.ts +56 -0
  179. package/dist/operations/run-feature-pipeline.operation.d.ts.map +1 -0
  180. package/dist/operations/run-feature-pipeline.operation.js +94 -0
  181. package/dist/operations/run-feature-pipeline.operation.js.map +1 -0
  182. package/dist/operations/score-record-set.operation.d.ts +47 -0
  183. package/dist/operations/score-record-set.operation.d.ts.map +1 -0
  184. package/dist/operations/score-record-set.operation.js +113 -0
  185. package/dist/operations/score-record-set.operation.js.map +1 -0
  186. package/dist/operations/start-experiment-session.operation.d.ts +66 -0
  187. package/dist/operations/start-experiment-session.operation.d.ts.map +1 -0
  188. package/dist/operations/start-experiment-session.operation.js +132 -0
  189. package/dist/operations/start-experiment-session.operation.js.map +1 -0
  190. package/dist/operations/train-model.operation.d.ts +50 -0
  191. package/dist/operations/train-model.operation.d.ts.map +1 -0
  192. package/dist/operations/train-model.operation.js +114 -0
  193. package/dist/operations/train-model.operation.js.map +1 -0
  194. package/dist/scheduling/index.d.ts +13 -0
  195. package/dist/scheduling/index.d.ts.map +1 -0
  196. package/dist/scheduling/index.js +13 -0
  197. package/dist/scheduling/index.js.map +1 -0
  198. package/dist/scheduling/scheduled-model-scoring.d.ts +169 -0
  199. package/dist/scheduling/scheduled-model-scoring.d.ts.map +1 -0
  200. package/dist/scheduling/scheduled-model-scoring.js +189 -0
  201. package/dist/scheduling/scheduled-model-scoring.js.map +1 -0
  202. package/dist/scoring/artifact-loader.d.ts +65 -0
  203. package/dist/scoring/artifact-loader.d.ts.map +1 -0
  204. package/dist/scoring/artifact-loader.js +97 -0
  205. package/dist/scoring/artifact-loader.js.map +1 -0
  206. package/dist/scoring/index.d.ts +26 -0
  207. package/dist/scoring/index.d.ts.map +1 -0
  208. package/dist/scoring/index.js +26 -0
  209. package/dist/scoring/index.js.map +1 -0
  210. package/dist/scoring/ml-model-inference-processor.d.ts +154 -0
  211. package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -0
  212. package/dist/scoring/ml-model-inference-processor.js +320 -0
  213. package/dist/scoring/ml-model-inference-processor.js.map +1 -0
  214. package/dist/scoring/ml-model-score-enricher.d.ts +80 -0
  215. package/dist/scoring/ml-model-score-enricher.d.ts.map +1 -0
  216. package/dist/scoring/ml-model-score-enricher.js +139 -0
  217. package/dist/scoring/ml-model-score-enricher.js.map +1 -0
  218. package/dist/scoring/register.d.ts +81 -0
  219. package/dist/scoring/register.d.ts.map +1 -0
  220. package/dist/scoring/register.js +105 -0
  221. package/dist/scoring/register.js.map +1 -0
  222. package/dist/scoring/scoring-binding.d.ts +72 -0
  223. package/dist/scoring/scoring-binding.d.ts.map +1 -0
  224. package/dist/scoring/scoring-binding.js +76 -0
  225. package/dist/scoring/scoring-binding.js.map +1 -0
  226. package/dist/scoring/scoring-process-shared.d.ts +105 -0
  227. package/dist/scoring/scoring-process-shared.d.ts.map +1 -0
  228. package/dist/scoring/scoring-process-shared.js +141 -0
  229. package/dist/scoring/scoring-process-shared.js.map +1 -0
  230. package/dist/scoring/scoring-process.d.ts +128 -0
  231. package/dist/scoring/scoring-process.d.ts.map +1 -0
  232. package/dist/scoring/scoring-process.js +146 -0
  233. package/dist/scoring/scoring-process.js.map +1 -0
  234. package/dist/scoring/seams.d.ts +40 -0
  235. package/dist/scoring/seams.d.ts.map +1 -0
  236. package/dist/scoring/seams.js +66 -0
  237. package/dist/scoring/seams.js.map +1 -0
  238. package/dist/scoring/startup-register.d.ts +49 -0
  239. package/dist/scoring/startup-register.d.ts.map +1 -0
  240. package/dist/scoring/startup-register.js +72 -0
  241. package/dist/scoring/startup-register.js.map +1 -0
  242. package/dist/scoring/types.d.ts +134 -0
  243. package/dist/scoring/types.d.ts.map +1 -0
  244. package/dist/scoring/types.js +26 -0
  245. package/dist/scoring/types.js.map +1 -0
  246. package/dist/training/artifact-store.d.ts +124 -0
  247. package/dist/training/artifact-store.d.ts.map +1 -0
  248. package/dist/training/artifact-store.js +163 -0
  249. package/dist/training/artifact-store.js.map +1 -0
  250. package/dist/training/index.d.ts +13 -0
  251. package/dist/training/index.d.ts.map +1 -0
  252. package/dist/training/index.js +13 -0
  253. package/dist/training/index.js.map +1 -0
  254. package/dist/training/seams.d.ts +57 -0
  255. package/dist/training/seams.d.ts.map +1 -0
  256. package/dist/training/seams.js +103 -0
  257. package/dist/training/seams.js.map +1 -0
  258. package/dist/training/training-engine.d.ts +96 -0
  259. package/dist/training/training-engine.d.ts.map +1 -0
  260. package/dist/training/training-engine.js +300 -0
  261. package/dist/training/training-engine.js.map +1 -0
  262. package/dist/training/types.d.ts +159 -0
  263. package/dist/training/types.d.ts.map +1 -0
  264. package/dist/training/types.js +16 -0
  265. package/dist/training/types.js.map +1 -0
  266. package/package.json +44 -7
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @module operations/start-experiment-session.operation
3
+ *
4
+ * **Start Experiment Session** Remote Operation — the server body for the
5
+ * Manual-mode `PredictiveStudio.StartExperimentSession` operation. The typed peer of
6
+ * the Run-Experiment *Action*: it validates that an **approved** modeling plan was
7
+ * supplied and runs it as an experiment session (in waves, under a budget,
8
+ * maintaining a leaderboard) via {@link ExperimentOrchestrator.runSession}.
9
+ *
10
+ * Per CLAUDE.md "transport-layer architecture", the operation is a THIN adapter —
11
+ * it carries no orchestration logic. The wave loop / leaderboard / budget gate live
12
+ * in the orchestrator, and the production deps wiring is shared with the action via
13
+ * {@link runExperimentSessionViaOrchestrator}.
14
+ *
15
+ * Marked `LongRunning`: it emits coarse start/finish progress. The orchestrator runs
16
+ * the session synchronously to completion (or a clean budget pause); it does not
17
+ * expose a per-wave progress hook today, so progress is bounded to lifecycle phases.
18
+ */
19
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
20
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
22
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
23
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
24
+ };
25
+ import { RegisterClass } from '@memberjunction/global';
26
+ import { BaseRemotableOperation } from '@memberjunction/core';
27
+ import { PredictiveStudioStartExperimentSessionOperation, } from '@memberjunction/core-entities';
28
+ import { validateModelingPlanSpec, validateBudget, } from '@memberjunction/predictive-studio-core';
29
+ import { ExperimentOrchestrator } from '../experiment/experiment-orchestrator.js';
30
+ import { runExperimentSessionViaOrchestrator } from './delegation.js';
31
+ /**
32
+ * Server implementation of `PredictiveStudio.StartExperimentSession`. Extends the
33
+ * CodeGen-emitted {@link PredictiveStudioStartExperimentSessionOperation} base
34
+ * (`ExecutionMode='LongRunning'`, `RequiredScope='predictive:execute'`) and supplies
35
+ * only the body; registered last so it wins server-side dispatch.
36
+ */
37
+ let PredictiveStudioStartExperimentSessionServerOperation = class PredictiveStudioStartExperimentSessionServerOperation extends PredictiveStudioStartExperimentSessionOperation {
38
+ /** @inheritdoc */
39
+ async InternalExecute(input, provider, user, context) {
40
+ const plan = this.validatePlan(input.planSpec);
41
+ context.emitProgress({
42
+ OperationKey: this.OperationKey,
43
+ Processed: 0,
44
+ Status: 'Running',
45
+ Message: `Starting experiment session for goal: ${plan.Goal}`,
46
+ });
47
+ const result = await runExperimentSessionViaOrchestrator(plan, this.buildOptions(input), provider, user, this.orchestrator());
48
+ context.emitProgress({
49
+ OperationKey: this.OperationKey,
50
+ Processed: result.iterations.length,
51
+ Total: result.iterations.length,
52
+ Status: 'Running',
53
+ Message: `Session ${result.session.ID} finished (${result.stopReason}) across ${result.iterations.length} iteration(s).`,
54
+ });
55
+ return {
56
+ sessionId: result.session.ID,
57
+ experimentId: result.experiment.ID,
58
+ status: result.session.Status,
59
+ };
60
+ }
61
+ /**
62
+ * Validate the untrusted plan against the Core schema and enforce the approval
63
+ * gate. Experiment execution is gated on user approval (§9.1) — an unapproved
64
+ * (or malformed) plan is refused before any orchestration begins.
65
+ *
66
+ * NB: the server tsconfig runs with `strictNullChecks` OFF, under which the
67
+ * discriminated-union return does NOT narrow on `validation.ok`; we read the
68
+ * failure detail off the concrete failure shape (mirrors the Run-Experiment action).
69
+ */
70
+ validatePlan(rawPlan) {
71
+ if (!rawPlan) {
72
+ throw new Error('planSpec is required (the approved modeling plan to execute)');
73
+ }
74
+ const validation = validateModelingPlanSpec(rawPlan);
75
+ if (!validation.ok) {
76
+ const error = validation.error ?? 'unknown validation error';
77
+ throw new Error(`planSpec is not a valid modeling plan: ${error}`);
78
+ }
79
+ const plan = validation.value;
80
+ if (plan.Approved !== true) {
81
+ throw new Error('The planSpec is not approved. Experiment execution is gated on user approval — set Approved=true before starting.');
82
+ }
83
+ return plan;
84
+ }
85
+ /**
86
+ * Build the orchestrator run options from the input — an optional `ExperimentID`
87
+ * to attach the session to, an optional validated `Budget` override (else the
88
+ * plan's `ProposedBudget`), and an optional session name.
89
+ */
90
+ buildOptions(input) {
91
+ const options = {};
92
+ if (input.experimentId) {
93
+ options.experimentID = input.experimentId;
94
+ }
95
+ if (input.sessionName) {
96
+ options.sessionName = input.sessionName;
97
+ }
98
+ const budget = this.parseBudget(input.budget);
99
+ if (budget) {
100
+ options.budget = budget;
101
+ }
102
+ return options;
103
+ }
104
+ /**
105
+ * Validate the optional budget override. A malformed budget is NOT a hard failure
106
+ * — the plan's `ProposedBudget` is the downstream fallback — so this returns
107
+ * `undefined` on absence or invalidity rather than throwing (mirrors the action).
108
+ */
109
+ parseBudget(raw) {
110
+ if (!raw) {
111
+ return undefined;
112
+ }
113
+ const validation = validateBudget(raw);
114
+ return validation.ok ? validation.value : undefined;
115
+ }
116
+ /**
117
+ * The {@link ExperimentOrchestrator} to delegate to. Overridable so unit tests
118
+ * inject a mock with no live DB / sidecar (mirrors the Action's seam).
119
+ */
120
+ orchestrator() {
121
+ return new ExperimentOrchestrator();
122
+ }
123
+ };
124
+ PredictiveStudioStartExperimentSessionServerOperation = __decorate([
125
+ RegisterClass(BaseRemotableOperation, 'PredictiveStudio.StartExperimentSession')
126
+ ], PredictiveStudioStartExperimentSessionServerOperation);
127
+ export { PredictiveStudioStartExperimentSessionServerOperation };
128
+ /** Tree-shaking anchor — call from a server bootstrap to retain this registration. */
129
+ export function LoadPredictiveStudioStartExperimentSessionOperation() {
130
+ // intentionally empty
131
+ }
132
+ //# sourceMappingURL=start-experiment-session.operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-experiment-session.operation.js","sourceRoot":"","sources":["../../src/operations/start-experiment-session.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,+CAA+C,GAGhD,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,wBAAwB,EACxB,cAAc,GAGf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,mCAAmC,EAAE,MAAM,cAAc,CAAC;AAEnE;;;;;GAKG;AAEI,IAAM,qDAAqD,GAA3D,MAAM,qDAAsD,SAAQ,+CAA+C;IACxH,kBAAkB;IACR,KAAK,CAAC,eAAe,CAC7B,KAAkD,EAClD,QAA2B,EAC3B,IAAc,EACd,OAA8B;QAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/C,OAAO,CAAC,YAAY,CAAC;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,yCAAyC,IAAI,CAAC,IAAI,EAAE;SAC9D,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,mCAAmC,CACtD,IAAI,EACJ,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EACxB,QAAQ,EAC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KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAC5C,CAAC;QACD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAC1C,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACO,WAAW,CAAC,GAA0D;QAC9E,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,YAAY;QACpB,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC;CACF,CAAA;AA3GY,qDAAqD;IADjE,aAAa,CAAC,sBAAsB,EAAE,yCAAyC,CAAC;GACpE,qDAAqD,CA2GjE;;AAKD,sFAAsF;AACtF,MAAM,UAAU,mDAAmD;IACjE,sBAAsB;AACxB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @module operations/train-model.operation
3
+ *
4
+ * **Train ML Model** Remote Operation — the server body for the Manual-mode
5
+ * `PredictiveStudio.TrainModel` operation. It is the typed peer of the Train
6
+ * *Action*: an agent / UI / workflow (client or in-process) invokes the operation
7
+ * by key, the framework applies the scope / permission gates, and this subclass
8
+ * maps the typed input → `TrainingEngine.trainModel` → the typed output.
9
+ *
10
+ * Per CLAUDE.md "transport-layer architecture", the operation is a THIN adapter —
11
+ * it carries no training logic. The actual orchestration (locked-holdout carve,
12
+ * sidecar `/train`, immutable model persist, leakage flag) lives in the engine, and
13
+ * the production wiring is shared with the Train action via {@link trainModelViaEngine}.
14
+ *
15
+ * Marked `LongRunning` (training can take a while): it emits coarse start/finish
16
+ * progress through the server context. The engine does not expose a per-epoch
17
+ * progress hook today, so progress is bounded to the lifecycle phases rather than
18
+ * fabricated row counts.
19
+ */
20
+ import type { IMetadataProvider, UserInfo } from '@memberjunction/core';
21
+ import { type RemoteOpServerContext } from '@memberjunction/core';
22
+ import { PredictiveStudioTrainModelOperation, type PredictiveStudioTrainModelInput, type PredictiveStudioTrainModelOutput } from '@memberjunction/core-entities';
23
+ import type { TrainModelInput } from '../training/types.js';
24
+ import { TrainingEngine } from '../training/training-engine.js';
25
+ /**
26
+ * Server implementation of `PredictiveStudio.TrainModel`. Extends the CodeGen-emitted
27
+ * {@link PredictiveStudioTrainModelOperation} base (which carries the `OperationKey`,
28
+ * `ExecutionMode='LongRunning'`, and `RequiredScope='predictive:execute'`) and
29
+ * supplies only the body; registered last so it wins server-side dispatch.
30
+ */
31
+ export declare class PredictiveStudioTrainModelServerOperation extends PredictiveStudioTrainModelOperation {
32
+ /** @inheritdoc */
33
+ protected InternalExecute(input: PredictiveStudioTrainModelInput, provider: IMetadataProvider, user: UserInfo, context: RemoteOpServerContext): Promise<PredictiveStudioTrainModelOutput>;
34
+ /**
35
+ * Map the operation's typed input onto the engine's {@link TrainModelInput}.
36
+ * The shapes are nearly 1:1; `labelEventDates` is the only field that differs —
37
+ * the wire shape carries ISO date strings, the engine wants `Date`s.
38
+ */
39
+ protected toEngineInput(input: PredictiveStudioTrainModelInput): TrainModelInput;
40
+ /** Parse the wire's `{ recordKey: ISO-string }` label-event map into `Date`s. */
41
+ protected parseLabelEventDates(map: Record<string, string>): Record<string, Date>;
42
+ /**
43
+ * The {@link TrainingEngine} instance to delegate to. Overridable so unit tests
44
+ * inject a mock engine with no live DB / sidecar (mirrors the Action's seam).
45
+ */
46
+ protected engine(): TrainingEngine;
47
+ }
48
+ /** Tree-shaking anchor — call from a server bootstrap to retain this registration. */
49
+ export declare function LoadPredictiveStudioTrainModelOperation(): void;
50
+ //# sourceMappingURL=train-model.operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-model.operation.d.ts","sourceRoot":"","sources":["../../src/operations/train-model.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,mCAAmC,EACnC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACtC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;;;;GAKG;AACH,qBACa,yCAA0C,SAAQ,mCAAmC;IAChG,kBAAkB;cACF,eAAe,CAC7B,KAAK,EAAE,+BAA+B,EACtC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,gCAAgC,CAAC;IAgC5C;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,+BAA+B,GAAG,eAAe;IAoBhF,iFAAiF;IACjF,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IAQjF;;;OAGG;IACH,SAAS,CAAC,MAAM,IAAI,cAAc;CAGnC;AAED,sFAAsF;AACtF,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @module operations/train-model.operation
3
+ *
4
+ * **Train ML Model** Remote Operation — the server body for the Manual-mode
5
+ * `PredictiveStudio.TrainModel` operation. It is the typed peer of the Train
6
+ * *Action*: an agent / UI / workflow (client or in-process) invokes the operation
7
+ * by key, the framework applies the scope / permission gates, and this subclass
8
+ * maps the typed input → `TrainingEngine.trainModel` → the typed output.
9
+ *
10
+ * Per CLAUDE.md "transport-layer architecture", the operation is a THIN adapter —
11
+ * it carries no training logic. The actual orchestration (locked-holdout carve,
12
+ * sidecar `/train`, immutable model persist, leakage flag) lives in the engine, and
13
+ * the production wiring is shared with the Train action via {@link trainModelViaEngine}.
14
+ *
15
+ * Marked `LongRunning` (training can take a while): it emits coarse start/finish
16
+ * progress through the server context. The engine does not expose a per-epoch
17
+ * progress hook today, so progress is bounded to the lifecycle phases rather than
18
+ * fabricated row counts.
19
+ */
20
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
21
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
22
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
23
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
25
+ };
26
+ import { RegisterClass } from '@memberjunction/global';
27
+ import { BaseRemotableOperation } from '@memberjunction/core';
28
+ import { PredictiveStudioTrainModelOperation, } from '@memberjunction/core-entities';
29
+ import { TrainingEngine } from '../training/training-engine.js';
30
+ import { trainModelViaEngine, wasTrainingLeakageFlagged } from './delegation.js';
31
+ /**
32
+ * Server implementation of `PredictiveStudio.TrainModel`. Extends the CodeGen-emitted
33
+ * {@link PredictiveStudioTrainModelOperation} base (which carries the `OperationKey`,
34
+ * `ExecutionMode='LongRunning'`, and `RequiredScope='predictive:execute'`) and
35
+ * supplies only the body; registered last so it wins server-side dispatch.
36
+ */
37
+ let PredictiveStudioTrainModelServerOperation = class PredictiveStudioTrainModelServerOperation extends PredictiveStudioTrainModelOperation {
38
+ /** @inheritdoc */
39
+ async InternalExecute(input, provider, user, context) {
40
+ if (!input?.pipelineId) {
41
+ throw new Error('pipelineId is required');
42
+ }
43
+ context.emitProgress({
44
+ OperationKey: this.OperationKey,
45
+ Processed: 0,
46
+ Status: 'Running',
47
+ Message: `Training model from pipeline ${input.pipelineId}…`,
48
+ });
49
+ const result = await trainModelViaEngine(this.toEngineInput(input), provider, user, this.engine());
50
+ context.emitProgress({
51
+ OperationKey: this.OperationKey,
52
+ Processed: 1,
53
+ Total: 1,
54
+ Status: 'Running',
55
+ Message: `Trained model ${result.model.ID} (v${result.model.Version}).`,
56
+ });
57
+ return {
58
+ modelId: result.model.ID,
59
+ trainingRunId: result.run.ID,
60
+ version: result.model.Version,
61
+ holdoutMetrics: result.model.HoldoutMetrics ?? undefined,
62
+ leakageFlagged: wasTrainingLeakageFlagged(result),
63
+ status: result.model.Status,
64
+ };
65
+ }
66
+ /**
67
+ * Map the operation's typed input onto the engine's {@link TrainModelInput}.
68
+ * The shapes are nearly 1:1; `labelEventDates` is the only field that differs —
69
+ * the wire shape carries ISO date strings, the engine wants `Date`s.
70
+ */
71
+ toEngineInput(input) {
72
+ const engineInput = { pipelineId: input.pipelineId };
73
+ if (input.experimentSessionIterationId) {
74
+ engineInput.experimentSessionIterationId = input.experimentSessionIterationId;
75
+ }
76
+ if (input.maxRows != null) {
77
+ engineInput.maxRows = input.maxRows;
78
+ }
79
+ if (input.primaryKeyField) {
80
+ engineInput.primaryKeyField = input.primaryKeyField;
81
+ }
82
+ if (input.sidecarVersion) {
83
+ engineInput.sidecarVersion = input.sidecarVersion;
84
+ }
85
+ if (input.labelEventDates) {
86
+ engineInput.labelEventDates = this.parseLabelEventDates(input.labelEventDates);
87
+ }
88
+ return engineInput;
89
+ }
90
+ /** Parse the wire's `{ recordKey: ISO-string }` label-event map into `Date`s. */
91
+ parseLabelEventDates(map) {
92
+ const out = {};
93
+ for (const [key, iso] of Object.entries(map)) {
94
+ out[key] = new Date(iso);
95
+ }
96
+ return out;
97
+ }
98
+ /**
99
+ * The {@link TrainingEngine} instance to delegate to. Overridable so unit tests
100
+ * inject a mock engine with no live DB / sidecar (mirrors the Action's seam).
101
+ */
102
+ engine() {
103
+ return new TrainingEngine();
104
+ }
105
+ };
106
+ PredictiveStudioTrainModelServerOperation = __decorate([
107
+ RegisterClass(BaseRemotableOperation, 'PredictiveStudio.TrainModel')
108
+ ], PredictiveStudioTrainModelServerOperation);
109
+ export { PredictiveStudioTrainModelServerOperation };
110
+ /** Tree-shaking anchor — call from a server bootstrap to retain this registration. */
111
+ export function LoadPredictiveStudioTrainModelOperation() {
112
+ // intentionally empty
113
+ }
114
+ //# sourceMappingURL=train-model.operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-model.operation.js","sourceRoot":"","sources":["../../src/operations/train-model.operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,mCAAmC,GAGpC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE9E;;;;;GAKG;AAEI,IAAM,yCAAyC,GAA/C,MAAM,yCAA0C,SAAQ,mCAAmC;IAChG,kBAAkB;IACR,KAAK,CAAC,eAAe,CAC7B,KAAsC,EACtC,QAA2B,EAC3B,IAAc,EACd,OAA8B;QAE9B,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,CAAC,YAAY,CAAC;YACnB,YAAY,EA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D,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,WAAW,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QACpD,CAAC;QACD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,iFAAiF;IACvE,oBAAoB,CAAC,GAA2B;QACxD,MAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;OAGG;IACO,MAAM;QACd,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;CACF,CAAA;AAhFY,yCAAyC;IADrD,aAAa,CAAC,sBAAsB,EAAE,6BAA6B,CAAC;GACxD,yCAAyC,CAgFrD;;AAED,sFAAsF;AACtF,MAAM,UAAU,uCAAuC;IACrD,sBAAsB;AACxB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module scheduling
3
+ *
4
+ * Barrel for the Predictive Studio **scheduling** layer (plan PS2-6) — the
5
+ * {@link createScheduledModelScoring} helper that binds a trained model to write
6
+ * its prediction into a target entity column on a recurring schedule, by assembling
7
+ * a single scheduled `MJ: Record Processes` row over the existing Record Set
8
+ * Processing + Scheduling substrates (no new scheduling/dispatch/write-back code).
9
+ *
10
+ * See `./scheduled-model-scoring` for the full flow.
11
+ */
12
+ export * from './scheduled-model-scoring.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scheduling/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module scheduling
3
+ *
4
+ * Barrel for the Predictive Studio **scheduling** layer (plan PS2-6) — the
5
+ * {@link createScheduledModelScoring} helper that binds a trained model to write
6
+ * its prediction into a target entity column on a recurring schedule, by assembling
7
+ * a single scheduled `MJ: Record Processes` row over the existing Record Set
8
+ * Processing + Scheduling substrates (no new scheduling/dispatch/write-back code).
9
+ *
10
+ * See `./scheduled-model-scoring` for the full flow.
11
+ */
12
+ export * from './scheduled-model-scoring.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scheduling/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * @module scheduling/scheduled-model-scoring
3
+ *
4
+ * **Scheduled model scoring** (plan PS2-6 — the north-star enabler). A one-call way
5
+ * to bind a trained `MJ: ML Models` to write its prediction into a target entity
6
+ * column on a recurring schedule (e.g. monthly): "build a model, write the renewal
7
+ * probability back into the member record, and re-score it on the 1st of every
8
+ * month." This is the helper the Model Dev Agent fulfils that goal with.
9
+ *
10
+ * ## How it works (composition, no new substrate)
11
+ * Everything underneath already exists; this helper just assembles a single
12
+ * `MJ: Record Processes` row that the existing machinery picks up:
13
+ *
14
+ * 1. {@link createScheduledModelScoring} creates + saves a Record Process with
15
+ * `WorkType='ML Model'` (the runtime-registered scoring work type, PS2-1),
16
+ * a `Configuration` of `{ modelId, primaryKeyField }`, an `OutputMapping` of
17
+ * `{ fields: { <outputField>: '$.score' } }` (write the prediction into a
18
+ * column), and `ScheduleEnabled=true` + a cron expression for the cadence.
19
+ * 2. Saving that row with `Status='Active'` + `ScheduleEnabled=true` + a
20
+ * `CronExpression` auto-creates an owned `MJ: Scheduled Jobs` row (via
21
+ * `MJRecordProcessEntityServer.Save → reconcileScheduledJob`).
22
+ * 3. `SchedulingEngine` dispatches that job on its cron through
23
+ * `RecordProcessScheduledJobDriver → RecordProcessExecutor.RunByID(...)`,
24
+ * which resolves the scope, scores each row with the model, and writes the
25
+ * prediction back per the `OutputMapping`.
26
+ * 4. AFTER the Record Process is saved, this helper also creates a
27
+ * `MJ: ML Model Scoring Bindings` row (`Mode='Scheduled'`) tying the model to
28
+ * that Record Process + target entity/column. The binding is the **lineage
29
+ * record** the new UX surfaces read — the model-prediction form panel and the
30
+ * "Models in Production" dashboard both list operationalized models from these
31
+ * binding rows — so without it the scheduled scoring would run but be invisible.
32
+ *
33
+ * So binding a model to a recurring write-back is a single create-and-save (plus a
34
+ * lineage binding) — no new scheduling, dispatch, or write-back code. This module
35
+ * only validates inputs, maps a cadence to a cron string, populates that one Record
36
+ * Process row, and records the binding for it.
37
+ *
38
+ * The shape + field-population primitives (scope model, value-kind → result-ref,
39
+ * `Configuration` / `OutputMapping` serialization, scope application, validation,
40
+ * entity resolution, lineage-binding creation) are shared with the on-demand sibling
41
+ * ({@link module:scoring/scoring-process}) in {@link module:scoring/scoring-process-shared};
42
+ * this module composes them and owns only the schedule-specific bits (cadence → cron).
43
+ *
44
+ * The `'ML Model'` `WorkType` is a runtime-registered extension (PS2-1) that the
45
+ * CodeGen'd `WorkType` value-list union (`'Action' | 'Agent' | 'FieldRules' |
46
+ * 'Infer'`) cannot represent, so it is set via `rp.Set('WorkType', 'ML Model')` —
47
+ * the same legitimate, documented exception PS2-1's scoring path uses.
48
+ */
49
+ import { type UserInfo, type IMetadataProvider } from '@memberjunction/core';
50
+ import type { MJRecordProcessEntity, MJMLModelScoringBindingEntity } from '@memberjunction/core-entities';
51
+ import { type ScoringValueKind, type ScoringScope } from '../scoring/scoring-process-shared.js';
52
+ export type { ScoringValueKind } from '../scoring/scoring-process-shared.js';
53
+ /**
54
+ * Recurrence for the scheduled scoring run. The named cadences map to a fixed cron
55
+ * (see {@link CADENCE_CRON}); supply `{ cron }` for any other recurrence.
56
+ */
57
+ export type ScoringCadence = 'Monthly' | 'Weekly' | 'Daily' | {
58
+ cron: string;
59
+ };
60
+ /**
61
+ * The scope of records each scheduled run scores. Exactly one selector must be
62
+ * populated — the common case is a `filter`, but a saved `viewId`/`listId` and `all`
63
+ * (the whole entity) are supported too. An alias of the shared {@link ScoringScope}
64
+ * shape, kept under this module's long-standing name for backwards compatibility.
65
+ */
66
+ export type ScheduledScoringScope = ScoringScope;
67
+ /**
68
+ * Inputs for {@link createScheduledModelScoring}. The required trio — `modelId`,
69
+ * `targetEntityName`, and exactly one `scope` selector — is the minimum to bind a
70
+ * model to a recurring scoring run; everything else has a sensible default (monthly
71
+ * cadence, `ID` primary key, numeric score, UTC, generated name).
72
+ *
73
+ * Two output modes, driven by whether `outputField` is supplied:
74
+ * - **Write-back** (`outputField` present): each run writes the prediction into that
75
+ * target column AND a `MJ: ML Model Scoring Bindings` lineage row is created.
76
+ * - **Generic** (`outputField` omitted): each run records its predictions in the
77
+ * process run history (`MJ: Process Run Details`) only — no write-back column and
78
+ * no scoring binding.
79
+ */
80
+ export interface ScheduleModelScoringOptions {
81
+ /** The `MJ: ML Models` id to score with. */
82
+ modelId: string;
83
+ /** The entity whose rows are scored (e.g. `'Memberships'`). */
84
+ targetEntityName: string;
85
+ /**
86
+ * Optional. The target-entity column to write the prediction into (e.g.
87
+ * `'RenewalScore'`). **Omit for generic output** — each run's predictions are
88
+ * recorded in the process run history (`MJ: Process Run Details`) only; no
89
+ * write-back column and no scoring binding are created.
90
+ */
91
+ outputField?: string;
92
+ /** The records each run scores. Populate EXACTLY ONE of: `filter`, `viewId`, `listId`, `all`. */
93
+ scope: ScheduledScoringScope;
94
+ /** Recurrence; defaults to `'Monthly'` (the 1st of every month at 00:00). */
95
+ cadence?: ScoringCadence;
96
+ /** Primary-key field on the target entity (defaults to `'ID'`). */
97
+ primaryKeyField?: string;
98
+ /** Which prediction value to write — numeric `'score'` (default) or `'class'` label. */
99
+ valueKind?: ScoringValueKind;
100
+ /** Optional Record Process name; a descriptive default is generated when omitted. */
101
+ name?: string;
102
+ /** Timezone the cron is evaluated in (defaults to `'UTC'`). */
103
+ timezone?: string;
104
+ /** Server-side context user (required for data isolation + audit on the saved row). */
105
+ contextUser?: UserInfo;
106
+ /** Metadata provider to create the entity object against (defaults to the global). */
107
+ provider?: IMetadataProvider;
108
+ }
109
+ /**
110
+ * The cron expression each named {@link ScoringCadence} maps to.
111
+ * - `Monthly` → `0 0 1 * *` (00:00 on the 1st of every month)
112
+ * - `Weekly` → `0 0 * * 0` (00:00 every Sunday)
113
+ * - `Daily` → `0 0 * * *` (00:00 every day)
114
+ */
115
+ export declare const CADENCE_CRON: Readonly<Record<'Monthly' | 'Weekly' | 'Daily', string>>;
116
+ /**
117
+ * The result of {@link createScheduledModelScoring}: the saved scheduled Record
118
+ * Process AND — in write-back mode — its lineage binding. The Record Process is the
119
+ * row that *does* the recurring scoring; the `MJ: ML Model Scoring Bindings` row
120
+ * *records* it (the latter is what the model-prediction form panel and "Models in
121
+ * Production" dashboard read).
122
+ *
123
+ * `binding` is `null` in **generic** mode (no `outputField`): there is no write-back
124
+ * column to bind, so no lineage row is created — predictions live in the process run
125
+ * history (`MJ: Process Run Details`) only.
126
+ */
127
+ export interface ScheduledModelScoringResult {
128
+ /** The saved scheduled `MJ: Record Processes` entity (its owned scheduled job already reconciled). */
129
+ recordProcess: MJRecordProcessEntity;
130
+ /**
131
+ * The saved `MJ: ML Model Scoring Bindings` lineage row (`Mode='Scheduled'`) in
132
+ * write-back mode, or `null` in generic mode (no `outputField`, no binding).
133
+ */
134
+ binding: MJMLModelScoringBindingEntity | null;
135
+ }
136
+ /**
137
+ * Create and save a scheduled Record Process that scores `targetEntity`'s rows with
138
+ * `modelId` on a recurring cadence. Operates in one of two modes, driven by whether
139
+ * `opts.outputField` is supplied:
140
+ *
141
+ * - **Write-back** (`outputField` present): each run writes the prediction into that
142
+ * target column (via the Record Process `OutputMapping`), AND this helper records a
143
+ * `MJ: ML Model Scoring Bindings` lineage row (`Mode='Scheduled'`) tying the model →
144
+ * Record Process → target entity/column so the operationalized model is discoverable
145
+ * by the UX surfaces that read those bindings. `result.binding` is the saved row.
146
+ * - **Generic** (`outputField` omitted): no `OutputMapping` is set and no binding is
147
+ * created — each run's predictions are recorded in the process run history
148
+ * (`MJ: Process Run Details`) only. `result.binding` is `null`.
149
+ *
150
+ * In both modes, saving the Record Process auto-creates its owned `MJ: Scheduled Jobs`
151
+ * row (so the run is live on the schedule immediately).
152
+ *
153
+ * @param opts the model + target + scope + cadence (see {@link ScheduleModelScoringOptions})
154
+ * @returns the saved Record Process AND — in write-back mode — its scoring binding
155
+ * (`null` in generic mode); see {@link ScheduledModelScoringResult}
156
+ * @throws if a required input is missing, the scope is not exactly one selector, the
157
+ * target entity is unknown, the Record Process fails to save, or — in write-back mode,
158
+ * after the Record Process was saved — the binding fails to save (the message carries
159
+ * the cause). The binding save is intentionally fail-loud (not swallowed): a saved RP
160
+ * without a binding would run invisibly to the lineage UX, so we surface the inconsistency.
161
+ */
162
+ export declare function createScheduledModelScoring(opts: ScheduleModelScoringOptions): Promise<ScheduledModelScoringResult>;
163
+ /**
164
+ * Map a {@link ScoringCadence} to its cron expression. Named cadences resolve via
165
+ * {@link CADENCE_CRON}; an explicit `{ cron }` is passed through (trimmed). Defaults
166
+ * to `'Monthly'` when no cadence is supplied.
167
+ */
168
+ export declare function cadenceToCron(cadence: ScoringCadence | undefined): string;
169
+ //# sourceMappingURL=scheduled-model-scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-model-scoring.d.ts","sourceRoot":"","sources":["../../src/scheduling/scheduled-model-scoring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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