@memberjunction/predictive-studio 0.0.1 → 5.45.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.
- package/README.md +101 -28
- package/dist/actions/base-predictive-studio.action.d.ts +63 -0
- package/dist/actions/base-predictive-studio.action.d.ts.map +1 -0
- package/dist/actions/base-predictive-studio.action.js +125 -0
- package/dist/actions/base-predictive-studio.action.js.map +1 -0
- package/dist/actions/index.d.ts +38 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +49 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/model-scoring-action-generator.d.ts +108 -0
- package/dist/actions/model-scoring-action-generator.d.ts.map +1 -0
- package/dist/actions/model-scoring-action-generator.js +316 -0
- package/dist/actions/model-scoring-action-generator.js.map +1 -0
- package/dist/actions/promote-model.action.d.ts +102 -0
- package/dist/actions/promote-model.action.d.ts.map +1 -0
- package/dist/actions/promote-model.action.js +132 -0
- package/dist/actions/promote-model.action.js.map +1 -0
- package/dist/actions/promote-model.gate.d.ts +77 -0
- package/dist/actions/promote-model.gate.d.ts.map +1 -0
- package/dist/actions/promote-model.gate.js +205 -0
- package/dist/actions/promote-model.gate.js.map +1 -0
- package/dist/actions/run-experiment.action.d.ts +60 -0
- package/dist/actions/run-experiment.action.d.ts.map +1 -0
- package/dist/actions/run-experiment.action.js +134 -0
- package/dist/actions/run-experiment.action.js.map +1 -0
- package/dist/actions/run-experiment.deps.d.ts +47 -0
- package/dist/actions/run-experiment.deps.d.ts.map +1 -0
- package/dist/actions/run-experiment.deps.js +71 -0
- package/dist/actions/run-experiment.deps.js.map +1 -0
- package/dist/actions/schedule-model-scoring.action.d.ts +71 -0
- package/dist/actions/schedule-model-scoring.action.d.ts.map +1 -0
- package/dist/actions/schedule-model-scoring.action.js +148 -0
- package/dist/actions/schedule-model-scoring.action.js.map +1 -0
- package/dist/actions/score-record-set.action.d.ts +133 -0
- package/dist/actions/score-record-set.action.d.ts.map +1 -0
- package/dist/actions/score-record-set.action.js +136 -0
- package/dist/actions/score-record-set.action.js.map +1 -0
- package/dist/actions/score-record-set.runner.d.ts +192 -0
- package/dist/actions/score-record-set.runner.d.ts.map +1 -0
- package/dist/actions/score-record-set.runner.js +416 -0
- package/dist/actions/score-record-set.runner.js.map +1 -0
- package/dist/actions/train-model.action.d.ts +57 -0
- package/dist/actions/train-model.action.d.ts.map +1 -0
- package/dist/actions/train-model.action.js +111 -0
- package/dist/actions/train-model.action.js.map +1 -0
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +14 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/model-dev-orchestrator-agent.d.ts +42 -0
- package/dist/agent/model-dev-orchestrator-agent.d.ts.map +1 -0
- package/dist/agent/model-dev-orchestrator-agent.js +76 -0
- package/dist/agent/model-dev-orchestrator-agent.js.map +1 -0
- package/dist/agent/modeling-plan-to-pipeline.d.ts +49 -0
- package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -0
- package/dist/agent/modeling-plan-to-pipeline.js +101 -0
- package/dist/agent/modeling-plan-to-pipeline.js.map +1 -0
- package/dist/agent/pipeline-builder-agent.d.ts +58 -0
- package/dist/agent/pipeline-builder-agent.d.ts.map +1 -0
- package/dist/agent/pipeline-builder-agent.js +101 -0
- package/dist/agent/pipeline-builder-agent.js.map +1 -0
- package/dist/agent/pipeline-builder.d.ts +67 -0
- package/dist/agent/pipeline-builder.d.ts.map +1 -0
- package/dist/agent/pipeline-builder.js +114 -0
- package/dist/agent/pipeline-builder.js.map +1 -0
- package/dist/experiment/concurrency.d.ts +41 -0
- package/dist/experiment/concurrency.d.ts.map +1 -0
- package/dist/experiment/concurrency.js +54 -0
- package/dist/experiment/concurrency.js.map +1 -0
- package/dist/experiment/experiment-orchestrator.d.ts +136 -0
- package/dist/experiment/experiment-orchestrator.d.ts.map +1 -0
- package/dist/experiment/experiment-orchestrator.js +408 -0
- package/dist/experiment/experiment-orchestrator.js.map +1 -0
- package/dist/experiment/index.d.ts +17 -0
- package/dist/experiment/index.d.ts.map +1 -0
- package/dist/experiment/index.js +17 -0
- package/dist/experiment/index.js.map +1 -0
- package/dist/experiment/leaderboard.d.ts +50 -0
- package/dist/experiment/leaderboard.d.ts.map +1 -0
- package/dist/experiment/leaderboard.js +91 -0
- package/dist/experiment/leaderboard.js.map +1 -0
- package/dist/experiment/seams.d.ts +95 -0
- package/dist/experiment/seams.d.ts.map +1 -0
- package/dist/experiment/seams.js +126 -0
- package/dist/experiment/seams.js.map +1 -0
- package/dist/experiment/types.d.ts +228 -0
- package/dist/experiment/types.d.ts.map +1 -0
- package/dist/experiment/types.js +19 -0
- package/dist/experiment/types.js.map +1 -0
- package/dist/experiment/wave-strategist.d.ts +31 -0
- package/dist/experiment/wave-strategist.d.ts.map +1 -0
- package/dist/experiment/wave-strategist.js +50 -0
- package/dist/experiment/wave-strategist.js.map +1 -0
- package/dist/feature-assembly/as-of.d.ts +74 -0
- package/dist/feature-assembly/as-of.d.ts.map +1 -0
- package/dist/feature-assembly/as-of.js +136 -0
- package/dist/feature-assembly/as-of.js.map +1 -0
- package/dist/feature-assembly/data-access.d.ts +114 -0
- package/dist/feature-assembly/data-access.d.ts.map +1 -0
- package/dist/feature-assembly/data-access.js +68 -0
- package/dist/feature-assembly/data-access.js.map +1 -0
- package/dist/feature-assembly/feature-assembly-executor.d.ts +273 -0
- package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -0
- package/dist/feature-assembly/feature-assembly-executor.js +521 -0
- package/dist/feature-assembly/feature-assembly-executor.js.map +1 -0
- package/dist/feature-assembly/index.d.ts +13 -0
- package/dist/feature-assembly/index.d.ts.map +1 -0
- package/dist/feature-assembly/index.js +13 -0
- package/dist/feature-assembly/index.js.map +1 -0
- package/dist/feature-assembly/leakage-guard.d.ts +86 -0
- package/dist/feature-assembly/leakage-guard.d.ts.map +1 -0
- package/dist/feature-assembly/leakage-guard.js +111 -0
- package/dist/feature-assembly/leakage-guard.js.map +1 -0
- package/dist/feature-assembly/vision-llm.d.ts +125 -0
- package/dist/feature-assembly/vision-llm.d.ts.map +1 -0
- package/dist/feature-assembly/vision-llm.js +211 -0
- package/dist/feature-assembly/vision-llm.js.map +1 -0
- package/dist/feature-pipelines/feature-pipeline-engine.d.ts +159 -0
- package/dist/feature-pipelines/feature-pipeline-engine.d.ts.map +1 -0
- package/dist/feature-pipelines/feature-pipeline-engine.js +298 -0
- package/dist/feature-pipelines/feature-pipeline-engine.js.map +1 -0
- package/dist/feature-pipelines/index.d.ts +13 -0
- package/dist/feature-pipelines/index.d.ts.map +1 -0
- package/dist/feature-pipelines/index.js +13 -0
- package/dist/feature-pipelines/index.js.map +1 -0
- package/dist/feature-pipelines/types.d.ts +72 -0
- package/dist/feature-pipelines/types.d.ts.map +1 -0
- package/dist/feature-pipelines/types.js +17 -0
- package/dist/feature-pipelines/types.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/maintenance/index.d.ts +19 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +19 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/maintenance-engine.d.ts +152 -0
- package/dist/maintenance/maintenance-engine.d.ts.map +1 -0
- package/dist/maintenance/maintenance-engine.js +412 -0
- package/dist/maintenance/maintenance-engine.js.map +1 -0
- package/dist/maintenance/metrics.d.ts +37 -0
- package/dist/maintenance/metrics.d.ts.map +1 -0
- package/dist/maintenance/metrics.js +85 -0
- package/dist/maintenance/metrics.js.map +1 -0
- package/dist/maintenance/seams.d.ts +85 -0
- package/dist/maintenance/seams.d.ts.map +1 -0
- package/dist/maintenance/seams.js +166 -0
- package/dist/maintenance/seams.js.map +1 -0
- package/dist/maintenance/types.d.ts +318 -0
- package/dist/maintenance/types.d.ts.map +1 -0
- package/dist/maintenance/types.js +27 -0
- package/dist/maintenance/types.js.map +1 -0
- package/dist/operations/__tests__/helpers.d.ts +30 -0
- package/dist/operations/__tests__/helpers.d.ts.map +1 -0
- package/dist/operations/__tests__/helpers.js +44 -0
- package/dist/operations/__tests__/helpers.js.map +1 -0
- package/dist/operations/control-experiment-session.operation.d.ts +33 -0
- package/dist/operations/control-experiment-session.operation.d.ts.map +1 -0
- package/dist/operations/control-experiment-session.operation.js +71 -0
- package/dist/operations/control-experiment-session.operation.js.map +1 -0
- package/dist/operations/create-scoring-process.operation.d.ts +30 -0
- package/dist/operations/create-scoring-process.operation.d.ts.map +1 -0
- package/dist/operations/create-scoring-process.operation.js +65 -0
- package/dist/operations/create-scoring-process.operation.js.map +1 -0
- package/dist/operations/delegation.d.ts +113 -0
- package/dist/operations/delegation.d.ts.map +1 -0
- package/dist/operations/delegation.js +139 -0
- package/dist/operations/delegation.js.map +1 -0
- package/dist/operations/index.d.ts +40 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +55 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/promote-model.operation.d.ts +57 -0
- package/dist/operations/promote-model.operation.d.ts.map +1 -0
- package/dist/operations/promote-model.operation.js +113 -0
- package/dist/operations/promote-model.operation.js.map +1 -0
- package/dist/operations/run-feature-pipeline.operation.d.ts +56 -0
- package/dist/operations/run-feature-pipeline.operation.d.ts.map +1 -0
- package/dist/operations/run-feature-pipeline.operation.js +94 -0
- package/dist/operations/run-feature-pipeline.operation.js.map +1 -0
- package/dist/operations/score-record-set.operation.d.ts +47 -0
- package/dist/operations/score-record-set.operation.d.ts.map +1 -0
- package/dist/operations/score-record-set.operation.js +113 -0
- package/dist/operations/score-record-set.operation.js.map +1 -0
- package/dist/operations/start-experiment-session.operation.d.ts +66 -0
- package/dist/operations/start-experiment-session.operation.d.ts.map +1 -0
- package/dist/operations/start-experiment-session.operation.js +132 -0
- package/dist/operations/start-experiment-session.operation.js.map +1 -0
- package/dist/operations/train-model.operation.d.ts +50 -0
- package/dist/operations/train-model.operation.d.ts.map +1 -0
- package/dist/operations/train-model.operation.js +114 -0
- package/dist/operations/train-model.operation.js.map +1 -0
- package/dist/scheduling/index.d.ts +13 -0
- package/dist/scheduling/index.d.ts.map +1 -0
- package/dist/scheduling/index.js +13 -0
- package/dist/scheduling/index.js.map +1 -0
- package/dist/scheduling/scheduled-model-scoring.d.ts +169 -0
- package/dist/scheduling/scheduled-model-scoring.d.ts.map +1 -0
- package/dist/scheduling/scheduled-model-scoring.js +189 -0
- package/dist/scheduling/scheduled-model-scoring.js.map +1 -0
- package/dist/scoring/artifact-loader.d.ts +65 -0
- package/dist/scoring/artifact-loader.d.ts.map +1 -0
- package/dist/scoring/artifact-loader.js +97 -0
- package/dist/scoring/artifact-loader.js.map +1 -0
- package/dist/scoring/index.d.ts +26 -0
- package/dist/scoring/index.d.ts.map +1 -0
- package/dist/scoring/index.js +26 -0
- package/dist/scoring/index.js.map +1 -0
- package/dist/scoring/ml-model-inference-processor.d.ts +154 -0
- package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -0
- package/dist/scoring/ml-model-inference-processor.js +320 -0
- package/dist/scoring/ml-model-inference-processor.js.map +1 -0
- package/dist/scoring/ml-model-score-enricher.d.ts +80 -0
- package/dist/scoring/ml-model-score-enricher.d.ts.map +1 -0
- package/dist/scoring/ml-model-score-enricher.js +139 -0
- package/dist/scoring/ml-model-score-enricher.js.map +1 -0
- package/dist/scoring/register.d.ts +81 -0
- package/dist/scoring/register.d.ts.map +1 -0
- package/dist/scoring/register.js +105 -0
- package/dist/scoring/register.js.map +1 -0
- package/dist/scoring/scoring-binding.d.ts +72 -0
- package/dist/scoring/scoring-binding.d.ts.map +1 -0
- package/dist/scoring/scoring-binding.js +76 -0
- package/dist/scoring/scoring-binding.js.map +1 -0
- package/dist/scoring/scoring-process-shared.d.ts +105 -0
- package/dist/scoring/scoring-process-shared.d.ts.map +1 -0
- package/dist/scoring/scoring-process-shared.js +141 -0
- package/dist/scoring/scoring-process-shared.js.map +1 -0
- package/dist/scoring/scoring-process.d.ts +128 -0
- package/dist/scoring/scoring-process.d.ts.map +1 -0
- package/dist/scoring/scoring-process.js +146 -0
- package/dist/scoring/scoring-process.js.map +1 -0
- package/dist/scoring/seams.d.ts +40 -0
- package/dist/scoring/seams.d.ts.map +1 -0
- package/dist/scoring/seams.js +66 -0
- package/dist/scoring/seams.js.map +1 -0
- package/dist/scoring/startup-register.d.ts +49 -0
- package/dist/scoring/startup-register.d.ts.map +1 -0
- package/dist/scoring/startup-register.js +72 -0
- package/dist/scoring/startup-register.js.map +1 -0
- package/dist/scoring/types.d.ts +134 -0
- package/dist/scoring/types.d.ts.map +1 -0
- package/dist/scoring/types.js +26 -0
- package/dist/scoring/types.js.map +1 -0
- package/dist/training/artifact-store.d.ts +124 -0
- package/dist/training/artifact-store.d.ts.map +1 -0
- package/dist/training/artifact-store.js +163 -0
- package/dist/training/artifact-store.js.map +1 -0
- package/dist/training/index.d.ts +13 -0
- package/dist/training/index.d.ts.map +1 -0
- package/dist/training/index.js +13 -0
- package/dist/training/index.js.map +1 -0
- package/dist/training/seams.d.ts +57 -0
- package/dist/training/seams.d.ts.map +1 -0
- package/dist/training/seams.js +103 -0
- package/dist/training/seams.js.map +1 -0
- package/dist/training/training-engine.d.ts +96 -0
- package/dist/training/training-engine.d.ts.map +1 -0
- package/dist/training/training-engine.js +300 -0
- package/dist/training/training-engine.js.map +1 -0
- package/dist/training/types.d.ts +159 -0
- package/dist/training/types.d.ts.map +1 -0
- package/dist/training/types.js +16 -0
- package/dist/training/types.js.map +1 -0
- package/package.json +44 -7
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/train-model.action
|
|
3
|
+
*
|
|
4
|
+
* **Train ML Model** action — the thin Action boundary over {@link TrainingEngine}
|
|
5
|
+
* (plan §3 / §12). It lets an agent / workflow / UI kick off a training run by
|
|
6
|
+
* pipeline id and read back the produced model id, its honest holdout metrics, and
|
|
7
|
+
* whether the run was leakage-flagged.
|
|
8
|
+
*
|
|
9
|
+
* Per CLAUDE.md "Actions are boundaries": this action does NOT do any training
|
|
10
|
+
* logic. It validates `PipelineID`, builds the engine's production dependency
|
|
11
|
+
* bundle (entity factory + record loader + sidecar + artifact store), delegates to
|
|
12
|
+
* `TrainingEngine.trainModel`, then maps the result onto output params. The engine
|
|
13
|
+
* and the deps bundle are created behind overridable factory seams so unit tests
|
|
14
|
+
* substitute mocks with no live DB and no sidecar.
|
|
15
|
+
*/
|
|
16
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
17
|
+
import { TrainingEngine } from '../training/training-engine.js';
|
|
18
|
+
import type { TrainingDeps, TrainModelResult } from '../training/types.js';
|
|
19
|
+
import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
|
|
20
|
+
/** The driver-class key this action registers under (matches the metadata row). */
|
|
21
|
+
export declare const TRAIN_MODEL_DRIVER_CLASS = "PredictiveStudioTrainModelAction";
|
|
22
|
+
/**
|
|
23
|
+
* Trains a model from a `MJ: ML Training Pipelines` definition and surfaces the
|
|
24
|
+
* resulting model id, holdout metrics, and leakage flag.
|
|
25
|
+
*
|
|
26
|
+
* Outputs: `ModelID` (string), `HoldoutMetrics` (JSON string), `LeakageFlagged`
|
|
27
|
+
* (boolean).
|
|
28
|
+
*/
|
|
29
|
+
export declare class PredictiveStudioTrainModelAction extends BasePredictiveStudioAction {
|
|
30
|
+
/** @inheritdoc */
|
|
31
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
32
|
+
/**
|
|
33
|
+
* Map the engine's {@link TrainModelResult} onto the action's output params.
|
|
34
|
+
* `LeakageFlagged` is read from the run's notes (the engine records a loud
|
|
35
|
+
* `LEAKAGE WARNING` there when single-feature dominance was detected — §6.4).
|
|
36
|
+
*/
|
|
37
|
+
protected mapResult(params: RunActionParams, result: TrainModelResult): ActionResultSimple;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the training run was leakage-flagged. The engine keeps the model in
|
|
40
|
+
* `Draft` and records a plain-language `LEAKAGE WARNING` in the run's `Notes`
|
|
41
|
+
* when single-feature dominance was detected (§6.4); we read that signal here.
|
|
42
|
+
*/
|
|
43
|
+
protected wasLeakageFlagged(result: TrainModelResult): boolean;
|
|
44
|
+
/** Construct the {@link TrainingEngine}. Overridable so tests inject a mock. */
|
|
45
|
+
protected createEngine(): TrainingEngine;
|
|
46
|
+
/**
|
|
47
|
+
* Build the engine's production dependency bundle from the action's run params
|
|
48
|
+
* (threading `ContextUser` + `Provider` for isolation/multi-provider
|
|
49
|
+
* correctness). Resolves the active File Storage Provider once and picks the
|
|
50
|
+
* artifact-store family accordingly (MJ-Files when a provider is active, local
|
|
51
|
+
* disk when none is — the dev/on-prem fallback; see
|
|
52
|
+
* {@link resolveActiveFileStorageProviderId}). Async so the provider lookup is
|
|
53
|
+
* part of the wiring; overridable so tests inject in-memory seams.
|
|
54
|
+
*/
|
|
55
|
+
protected buildDeps(params: RunActionParams): Promise<TrainingDeps>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=train-model.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"train-model.action.d.ts","sourceRoot":"","sources":["../../src/actions/train-model.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKxF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,mFAAmF;AACnF,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAE3E;;;;;;GAMG;AACH,qBACa,gCAAiC,SAAQ,0BAA0B;IAC9E,kBAAkB;cACF,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoBvF;;;;OAIG;IACH,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,GAAG,kBAAkB;IAY1F;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;IAM9D,gFAAgF;IAChF,SAAS,CAAC,YAAY,IAAI,cAAc;IAIxC;;;;;;;;OAQG;cACa,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;CAY1E"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/train-model.action
|
|
3
|
+
*
|
|
4
|
+
* **Train ML Model** action — the thin Action boundary over {@link TrainingEngine}
|
|
5
|
+
* (plan §3 / §12). It lets an agent / workflow / UI kick off a training run by
|
|
6
|
+
* pipeline id and read back the produced model id, its honest holdout metrics, and
|
|
7
|
+
* whether the run was leakage-flagged.
|
|
8
|
+
*
|
|
9
|
+
* Per CLAUDE.md "Actions are boundaries": this action does NOT do any training
|
|
10
|
+
* logic. It validates `PipelineID`, builds the engine's production dependency
|
|
11
|
+
* bundle (entity factory + record loader + sidecar + artifact store), delegates to
|
|
12
|
+
* `TrainingEngine.trainModel`, then maps the result onto output params. The engine
|
|
13
|
+
* and the deps bundle are created behind overridable factory seams so unit tests
|
|
14
|
+
* substitute mocks with no live DB and no sidecar.
|
|
15
|
+
*/
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
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;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
22
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
23
|
+
import { LogError } from '@memberjunction/core';
|
|
24
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
25
|
+
import { TrainingEngine } from '../training/training-engine.js';
|
|
26
|
+
import { MetadataEntityFactory, RunViewRecordLoader, MJSidecarTrainer } from '../training/seams.js';
|
|
27
|
+
import { resolveActiveFileStorageProviderId, buildArtifactStore } from '../training/artifact-store.js';
|
|
28
|
+
import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
|
|
29
|
+
/** The driver-class key this action registers under (matches the metadata row). */
|
|
30
|
+
export const TRAIN_MODEL_DRIVER_CLASS = 'PredictiveStudioTrainModelAction';
|
|
31
|
+
/**
|
|
32
|
+
* Trains a model from a `MJ: ML Training Pipelines` definition and surfaces the
|
|
33
|
+
* resulting model id, holdout metrics, and leakage flag.
|
|
34
|
+
*
|
|
35
|
+
* Outputs: `ModelID` (string), `HoldoutMetrics` (JSON string), `LeakageFlagged`
|
|
36
|
+
* (boolean).
|
|
37
|
+
*/
|
|
38
|
+
let PredictiveStudioTrainModelAction = class PredictiveStudioTrainModelAction extends BasePredictiveStudioAction {
|
|
39
|
+
/** @inheritdoc */
|
|
40
|
+
async InternalRunAction(params) {
|
|
41
|
+
try {
|
|
42
|
+
const pipelineId = this.getStringParam(params, 'PipelineID');
|
|
43
|
+
if (!pipelineId) {
|
|
44
|
+
return this.fail('VALIDATION_ERROR', 'PipelineID parameter is required');
|
|
45
|
+
}
|
|
46
|
+
const maxRows = this.getNumericParam(params, 'MaxRows');
|
|
47
|
+
const engine = this.createEngine();
|
|
48
|
+
const deps = await this.buildDeps(params);
|
|
49
|
+
const result = await engine.trainModel({ pipelineId, maxRows }, deps);
|
|
50
|
+
return this.mapResult(params, result);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
LogError(e);
|
|
54
|
+
return this.fail('TRAINING_FAILED', `Training failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Map the engine's {@link TrainModelResult} onto the action's output params.
|
|
59
|
+
* `LeakageFlagged` is read from the run's notes (the engine records a loud
|
|
60
|
+
* `LEAKAGE WARNING` there when single-feature dominance was detected — §6.4).
|
|
61
|
+
*/
|
|
62
|
+
mapResult(params, result) {
|
|
63
|
+
const leakageFlagged = this.wasLeakageFlagged(result);
|
|
64
|
+
this.addOutputParam(params, 'ModelID', result.model.ID);
|
|
65
|
+
this.addOutputParam(params, 'HoldoutMetrics', result.model.HoldoutMetrics ?? null);
|
|
66
|
+
this.addOutputParam(params, 'LeakageFlagged', leakageFlagged);
|
|
67
|
+
const note = leakageFlagged
|
|
68
|
+
? ' A single feature is doing almost all the predicting — a human must confirm this is not target leakage before the model is trusted.'
|
|
69
|
+
: '';
|
|
70
|
+
return this.ok(params, `Trained model ${result.model.ID} (v${result.model.Version}).${note}`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether the training run was leakage-flagged. The engine keeps the model in
|
|
74
|
+
* `Draft` and records a plain-language `LEAKAGE WARNING` in the run's `Notes`
|
|
75
|
+
* when single-feature dominance was detected (§6.4); we read that signal here.
|
|
76
|
+
*/
|
|
77
|
+
wasLeakageFlagged(result) {
|
|
78
|
+
return (result.run.Notes ?? '').includes('LEAKAGE WARNING');
|
|
79
|
+
}
|
|
80
|
+
// ----- injectable engine + deps seams (overridden in tests) ----------------
|
|
81
|
+
/** Construct the {@link TrainingEngine}. Overridable so tests inject a mock. */
|
|
82
|
+
createEngine() {
|
|
83
|
+
return new TrainingEngine();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build the engine's production dependency bundle from the action's run params
|
|
87
|
+
* (threading `ContextUser` + `Provider` for isolation/multi-provider
|
|
88
|
+
* correctness). Resolves the active File Storage Provider once and picks the
|
|
89
|
+
* artifact-store family accordingly (MJ-Files when a provider is active, local
|
|
90
|
+
* disk when none is — the dev/on-prem fallback; see
|
|
91
|
+
* {@link resolveActiveFileStorageProviderId}). Async so the provider lookup is
|
|
92
|
+
* part of the wiring; overridable so tests inject in-memory seams.
|
|
93
|
+
*/
|
|
94
|
+
async buildDeps(params) {
|
|
95
|
+
const entityFactory = new MetadataEntityFactory(params.Provider);
|
|
96
|
+
const providerId = await resolveActiveFileStorageProviderId(params.ContextUser, params.Provider);
|
|
97
|
+
return {
|
|
98
|
+
entityFactory,
|
|
99
|
+
recordLoader: new RunViewRecordLoader(),
|
|
100
|
+
sidecar: new MJSidecarTrainer(),
|
|
101
|
+
artifactStore: buildArtifactStore(providerId, entityFactory),
|
|
102
|
+
contextUser: params.ContextUser,
|
|
103
|
+
provider: params.Provider,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
PredictiveStudioTrainModelAction = __decorate([
|
|
108
|
+
RegisterClass(BaseAction, TRAIN_MODEL_DRIVER_CLASS)
|
|
109
|
+
], PredictiveStudioTrainModelAction);
|
|
110
|
+
export { PredictiveStudioTrainModelAction };
|
|
111
|
+
//# sourceMappingURL=train-model.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"train-model.action.js","sourceRoot":"","sources":["../../src/actions/train-model.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,kCAAkC,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;A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Q,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AA5EY,gCAAgC;IAD5C,aAAa,CAAC,UAAU,EAAE,wBAAwB,CAAC;GACvC,gCAAgC,CA4E5C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent
|
|
3
|
+
*
|
|
4
|
+
* The Predictive Studio Agent's deterministic builder layer:
|
|
5
|
+
* - {@link modelingPlanToPipelineConfig} — pure ModelingPlanSpec → pipeline-config mapper
|
|
6
|
+
* - {@link PredictiveStudioPipelineBuilder} — commits it to metadata, trains, publishes gated on trust
|
|
7
|
+
* - {@link PredictiveStudioPipelineBuilderAgent} — the code sub-agent wrapping the builder
|
|
8
|
+
* - {@link PredictiveStudioModelDevAgent} — the orchestrator that FORCES approve→build deterministically
|
|
9
|
+
*/
|
|
10
|
+
export * from './modeling-plan-to-pipeline.js';
|
|
11
|
+
export * from './pipeline-builder.js';
|
|
12
|
+
export * from './pipeline-builder-agent.js';
|
|
13
|
+
export * from './model-dev-orchestrator-agent.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent
|
|
3
|
+
*
|
|
4
|
+
* The Predictive Studio Agent's deterministic builder layer:
|
|
5
|
+
* - {@link modelingPlanToPipelineConfig} — pure ModelingPlanSpec → pipeline-config mapper
|
|
6
|
+
* - {@link PredictiveStudioPipelineBuilder} — commits it to metadata, trains, publishes gated on trust
|
|
7
|
+
* - {@link PredictiveStudioPipelineBuilderAgent} — the code sub-agent wrapping the builder
|
|
8
|
+
* - {@link PredictiveStudioModelDevAgent} — the orchestrator that FORCES approve→build deterministically
|
|
9
|
+
*/
|
|
10
|
+
export * from './modeling-plan-to-pipeline.js';
|
|
11
|
+
export * from './pipeline-builder.js';
|
|
12
|
+
export * from './pipeline-builder-agent.js';
|
|
13
|
+
export * from './model-dev-orchestrator-agent.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/model-dev-orchestrator-agent
|
|
3
|
+
*
|
|
4
|
+
* The Predictive Studio Agent's **orchestrator** — the DriverClass for the elevated Model Development
|
|
5
|
+
* Agent, modeled on `DatabaseDesignerAgent`. Its `determineNextStep` override makes the build
|
|
6
|
+
* DETERMINISTIC: once the user has approved the modeling plan, the LLM never gets to decide whether (or
|
|
7
|
+
* how) to build — the orchestrator FORCES routing to the `Pipeline Builder` code sub-agent, which
|
|
8
|
+
* crafts the pipeline + trains + publishes-gated-on-trust. Every other decision (gathering the goal,
|
|
9
|
+
* scouting data, designing experiments, asking for approval) stays LLM-driven via `super`.
|
|
10
|
+
*/
|
|
11
|
+
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
12
|
+
import type { ExecuteAgentParams, BaseAgentNextStep, AIPromptRunResult } from '@memberjunction/ai-core-plus';
|
|
13
|
+
import { MJAIAgentTypeEntity } from '@memberjunction/core-entities';
|
|
14
|
+
import type { PredictiveStudioBuildOutcome } from './pipeline-builder-agent.js';
|
|
15
|
+
/** The minimal payload slice the build decision reads (so it's callable with a partial in tests). */
|
|
16
|
+
type BuildDecisionState = {
|
|
17
|
+
Approved?: boolean;
|
|
18
|
+
BuildResult?: PredictiveStudioBuildOutcome;
|
|
19
|
+
};
|
|
20
|
+
/** The sub-agent NAME the orchestrator forces to once the plan is approved (matches the metadata). */
|
|
21
|
+
export declare const PIPELINE_BUILDER_SUBAGENT_NAME = "Pipeline Builder";
|
|
22
|
+
/**
|
|
23
|
+
* The deterministic decision: should the orchestrator force the build right now? True when the plan is
|
|
24
|
+
* approved (an explicit `Approved` flag OR a "build it" intent in the last user message) AND it hasn't
|
|
25
|
+
* been built yet (`BuildResult` absent). Pure → unit-testable without the agent framework.
|
|
26
|
+
*/
|
|
27
|
+
export declare function shouldForceBuild(payload: BuildDecisionState | undefined, lastUserText: string | null): boolean;
|
|
28
|
+
export declare class PredictiveStudioModelDevAgent extends BaseAgent {
|
|
29
|
+
/**
|
|
30
|
+
* Intercept the post-approval transition and force the deterministic builder; otherwise defer to the
|
|
31
|
+
* normal LLM-driven flow.
|
|
32
|
+
*/
|
|
33
|
+
protected determineNextStep<P>(params: ExecuteAgentParams, agentType: MJAIAgentTypeEntity, promptResult: AIPromptRunResult, currentPayload: P): Promise<BaseAgentNextStep<P>>;
|
|
34
|
+
/** Plain text of the most recent user message (normalizing string / content-block content). */
|
|
35
|
+
private lastUserMessageText;
|
|
36
|
+
/** Force a routed sub-agent step (the orchestrator runs again after the sub-agent returns). */
|
|
37
|
+
private buildSubAgentStep;
|
|
38
|
+
}
|
|
39
|
+
/** Tree-shaking anchor so the @RegisterClass side effect survives bundling. */
|
|
40
|
+
export declare function LoadPredictiveStudioModelDevAgent(): void;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=model-dev-orchestrator-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-dev-orchestrator-agent.d.ts","sourceRoot":"","sources":["../../src/agent/model-dev-orchestrator-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAsB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjI,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAkC,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAE7G,qGAAqG;AACrG,KAAK,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,4BAA4B,CAAA;CAAE,CAAC;AAE7F,sGAAsG;AACtG,eAAO,MAAM,8BAA8B,qBAAqB,CAAC;AAGjE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAK9G;AAED,qBACa,6BAA8B,SAAQ,SAAS;IAC1D;;;OAGG;cACsB,iBAAiB,CAAC,CAAC,EAC1C,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,mBAAmB,EAC9B,YAAY,EAAE,iBAAiB,EAC/B,cAAc,EAAE,CAAC,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAQhC,+FAA+F;IAC/F,OAAO,CAAC,mBAAmB;IAU3B,+FAA+F;IAC/F,OAAO,CAAC,iBAAiB;CAS1B;AAED,+EAA+E;AAC/E,wBAAgB,iCAAiC,IAAI,IAAI,CAExD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/model-dev-orchestrator-agent
|
|
3
|
+
*
|
|
4
|
+
* The Predictive Studio Agent's **orchestrator** — the DriverClass for the elevated Model Development
|
|
5
|
+
* Agent, modeled on `DatabaseDesignerAgent`. Its `determineNextStep` override makes the build
|
|
6
|
+
* DETERMINISTIC: once the user has approved the modeling plan, the LLM never gets to decide whether (or
|
|
7
|
+
* how) to build — the orchestrator FORCES routing to the `Pipeline Builder` code sub-agent, which
|
|
8
|
+
* crafts the pipeline + trains + publishes-gated-on-trust. Every other decision (gathering the goal,
|
|
9
|
+
* scouting data, designing experiments, asking for approval) stays LLM-driven via `super`.
|
|
10
|
+
*/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
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;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
18
|
+
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
19
|
+
/** The sub-agent NAME the orchestrator forces to once the plan is approved (matches the metadata). */
|
|
20
|
+
export const PIPELINE_BUILDER_SUBAGENT_NAME = 'Pipeline Builder';
|
|
21
|
+
const BUILD_MESSAGE = 'The plan is approved — build the pipeline, train it, and apply the publish gate now.';
|
|
22
|
+
/**
|
|
23
|
+
* The deterministic decision: should the orchestrator force the build right now? True when the plan is
|
|
24
|
+
* approved (an explicit `Approved` flag OR a "build it" intent in the last user message) AND it hasn't
|
|
25
|
+
* been built yet (`BuildResult` absent). Pure → unit-testable without the agent framework.
|
|
26
|
+
*/
|
|
27
|
+
export function shouldForceBuild(payload, lastUserText) {
|
|
28
|
+
if (payload?.BuildResult)
|
|
29
|
+
return false; // already built — don't loop
|
|
30
|
+
if (payload?.Approved === true)
|
|
31
|
+
return true;
|
|
32
|
+
const t = (lastUserText ?? '').toLowerCase();
|
|
33
|
+
return t.includes('build it') || t.includes('create it') || t.includes('build the prediction') || t.includes('build_now');
|
|
34
|
+
}
|
|
35
|
+
let PredictiveStudioModelDevAgent = class PredictiveStudioModelDevAgent extends BaseAgent {
|
|
36
|
+
/**
|
|
37
|
+
* Intercept the post-approval transition and force the deterministic builder; otherwise defer to the
|
|
38
|
+
* normal LLM-driven flow.
|
|
39
|
+
*/
|
|
40
|
+
async determineNextStep(params, agentType, promptResult, currentPayload) {
|
|
41
|
+
const payload = currentPayload;
|
|
42
|
+
if (shouldForceBuild(payload, this.lastUserMessageText(params))) {
|
|
43
|
+
return this.buildSubAgentStep(PIPELINE_BUILDER_SUBAGENT_NAME, BUILD_MESSAGE, currentPayload);
|
|
44
|
+
}
|
|
45
|
+
return super.determineNextStep(params, agentType, promptResult, currentPayload);
|
|
46
|
+
}
|
|
47
|
+
/** Plain text of the most recent user message (normalizing string / content-block content). */
|
|
48
|
+
lastUserMessageText(params) {
|
|
49
|
+
const messages = params.conversationMessages ?? [];
|
|
50
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
51
|
+
if (messages[i].role === 'user') {
|
|
52
|
+
return this.contentToString(messages[i].content);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** Force a routed sub-agent step (the orchestrator runs again after the sub-agent returns). */
|
|
58
|
+
buildSubAgentStep(agentName, message, currentPayload) {
|
|
59
|
+
return {
|
|
60
|
+
step: 'Sub-Agent',
|
|
61
|
+
terminate: false,
|
|
62
|
+
previousPayload: currentPayload,
|
|
63
|
+
newPayload: currentPayload,
|
|
64
|
+
subAgent: { name: agentName, message, terminateAfter: false },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
PredictiveStudioModelDevAgent = __decorate([
|
|
69
|
+
RegisterClass(BaseAgent, 'PredictiveStudioModelDevAgent')
|
|
70
|
+
], PredictiveStudioModelDevAgent);
|
|
71
|
+
export { PredictiveStudioModelDevAgent };
|
|
72
|
+
/** Tree-shaking anchor so the @RegisterClass side effect survives bundling. */
|
|
73
|
+
export function LoadPredictiveStudioModelDevAgent() {
|
|
74
|
+
/* no-op */
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=model-dev-orchestrator-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-dev-orchestrator-agent.js","sourceRoot":"","sources":["../../src/agent/model-dev-orchestrator-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAQtD,sGAAsG;AACtG,MAAM,CAAC,MAAM,8BAA8B,GAAG,kBAAkB,CAAC;AACjE,MAAM,aAAa,GAAG,sFAAsF,CAAC;AAE7G;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAuC,EAAE,YAA2B;IACnG,IAAI,OAAO,EAAE,WAAW;QAAE,OAAO,KAAK,CAAC,CAAC,6BAA6B;IACrE,IAAI,OAAO,EAAE,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5C,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC5H,CAAC;AAGM,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,SAAS;IAC1D;;;OAGG;IACgB,KAAK,CAAC,iBAAiB,CACxC,MAA0B,EAC1B,SAA8B,EAC9B,YAA+B,EAC/B,cAAiB;QAEjB,MAAM,OAAO,GAAG,cAA4D,CAAC;QAC7E,IAAI,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;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it turns the
|
|
5
|
+
* agent's strongly-typed, conversation-accumulated {@link ModelingPlanSpec} into the concrete
|
|
6
|
+
* `MJ: ML Training Pipelines` field shapes — `SourceBindings`, the `FeatureStep` DAG, `AsOfStrategy`,
|
|
7
|
+
* `LeakageGuard`, `ValidationStrategy`. This is pure code (no LLM, no DB), so the structure the
|
|
8
|
+
* builder commits to metadata is type-safe and never hallucinated — the same guarantee Database
|
|
9
|
+
* Designer and Agent Manager give for schema/agent metadata.
|
|
10
|
+
*
|
|
11
|
+
* Pure + framework-free (no entity/provider deps) → fully unit-testable with zero setup.
|
|
12
|
+
*/
|
|
13
|
+
import type { ModelingPlanSpec, SourceBinding, FeatureStepGraph, AsOfStrategy, LeakageGuard, ValidationStrategy, ProblemType } from '@memberjunction/predictive-studio-core';
|
|
14
|
+
/** The resolved, ready-to-persist configuration for one `MJ: ML Training Pipelines` row. */
|
|
15
|
+
export interface PipelineConfig {
|
|
16
|
+
/** Human-readable pipeline name (derived from the plan's Goal). */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Plain-language description carried onto the pipeline row. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** The training-unit entity NAME (resolved to TargetEntityID by the builder). */
|
|
21
|
+
targetEntityName: string;
|
|
22
|
+
/** Label column / expression. */
|
|
23
|
+
targetVariable: string;
|
|
24
|
+
/** Classification or regression. */
|
|
25
|
+
problemType: ProblemType;
|
|
26
|
+
/** The algorithm NAME the chosen experiment proposes (resolved to AlgorithmID by the builder). */
|
|
27
|
+
algorithmName: string;
|
|
28
|
+
/** Source bindings the features draw from. */
|
|
29
|
+
sourceBindings: SourceBinding[];
|
|
30
|
+
/** The assembled FeatureStep DAG. */
|
|
31
|
+
featureSteps: FeatureStepGraph;
|
|
32
|
+
/** Point-in-time assembly strategy. */
|
|
33
|
+
asOf: AsOfStrategy;
|
|
34
|
+
/** Leakage protection (deny-list + dominance threshold). */
|
|
35
|
+
leakageGuard: LeakageGuard;
|
|
36
|
+
/** Validation strategy. */
|
|
37
|
+
validation: ValidationStrategy;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Deterministically translate an approved {@link ModelingPlanSpec} into the concrete pipeline
|
|
41
|
+
* configuration the builder will persist. Throws on a spec that can't yield a trainable pipeline
|
|
42
|
+
* (no target entity, no target variable, or no proposed algorithm) — the builder surfaces these as a
|
|
43
|
+
* clean failure rather than creating a broken pipeline.
|
|
44
|
+
*
|
|
45
|
+
* @param spec the approved modeling plan the agent accumulated.
|
|
46
|
+
* @returns the resolved {@link PipelineConfig}.
|
|
47
|
+
*/
|
|
48
|
+
export declare function modelingPlanToPipelineConfig(spec: ModelingPlanSpec): PipelineConfig;
|
|
49
|
+
//# sourceMappingURL=modeling-plan-to-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modeling-plan-to-pipeline.d.ts","sourceRoot":"","sources":["../../src/agent/modeling-plan-to-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAEhB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACZ,MAAM,wCAAwC,CAAC;AAEhD,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,gBAAgB,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,WAAW,EAAE,WAAW,CAAC;IACzB,kGAAkG;IAClG,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,qCAAqC;IACrC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,uCAAuC;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,4DAA4D;IAC5D,YAAY,EAAE,YAAY,CAAC;IAC3B,2BAA2B;IAC3B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AA8DD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,GAAG,cAAc,CA0BnF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/modeling-plan-to-pipeline
|
|
3
|
+
*
|
|
4
|
+
* The DETERMINISTIC translation at the heart of the Predictive Studio Agent's builder: it turns the
|
|
5
|
+
* agent's strongly-typed, conversation-accumulated {@link ModelingPlanSpec} into the concrete
|
|
6
|
+
* `MJ: ML Training Pipelines` field shapes — `SourceBindings`, the `FeatureStep` DAG, `AsOfStrategy`,
|
|
7
|
+
* `LeakageGuard`, `ValidationStrategy`. This is pure code (no LLM, no DB), so the structure the
|
|
8
|
+
* builder commits to metadata is type-safe and never hallucinated — the same guarantee Database
|
|
9
|
+
* Designer and Agent Manager give for schema/agent metadata.
|
|
10
|
+
*
|
|
11
|
+
* Pure + framework-free (no entity/provider deps) → fully unit-testable with zero setup.
|
|
12
|
+
*/
|
|
13
|
+
/** Default single-feature-dominance threshold when the plan doesn't override it. */
|
|
14
|
+
const DEFAULT_DOMINANCE_THRESHOLD = 0.85;
|
|
15
|
+
/** The chosen experiment = the highest-priority (lowest `Priority` number) proposed experiment. */
|
|
16
|
+
function chooseExperiment(spec) {
|
|
17
|
+
const experiments = spec.ProposedExperiments ?? [];
|
|
18
|
+
if (experiments.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
return [...experiments].sort((a, b) => (a.Priority ?? 0) - (b.Priority ?? 0))[0];
|
|
21
|
+
}
|
|
22
|
+
/** Build the FeatureStep DAG from the selected candidate features (select raw cols; one-hot categoricals). */
|
|
23
|
+
function buildFeatureSteps(spec, featureSet) {
|
|
24
|
+
const all = spec.CandidateFeatures ?? [];
|
|
25
|
+
// Honor the chosen experiment's FeatureSet when present; otherwise use every candidate feature.
|
|
26
|
+
const selected = featureSet.length > 0 ? all.filter((f) => featureSet.includes(f.Name)) : all;
|
|
27
|
+
// Raw passthrough columns: numeric + categorical features (embedding/llm-derived are handled by
|
|
28
|
+
// their own step kinds and aren't simple row columns).
|
|
29
|
+
const rawColumns = selected.filter((f) => f.Kind === 'numeric' || f.Kind === 'categorical').map((f) => f.Name);
|
|
30
|
+
const steps = [];
|
|
31
|
+
if (rawColumns.length > 0) {
|
|
32
|
+
steps.push({ Id: 'select-raw', Kind: 'select', Columns: rawColumns });
|
|
33
|
+
}
|
|
34
|
+
// One-hot each categorical feature so the sidecar fits the vocabulary once and applies it everywhere.
|
|
35
|
+
for (const f of selected.filter((f) => f.Kind === 'categorical')) {
|
|
36
|
+
steps.push({ Id: `onehot-${f.Name}`, Kind: 'onehot', Column: f.Name });
|
|
37
|
+
}
|
|
38
|
+
return { Steps: steps };
|
|
39
|
+
}
|
|
40
|
+
/** Source bindings from the plan's candidate sources (drop the agent's `Why` rationale). */
|
|
41
|
+
function buildSourceBindings(spec) {
|
|
42
|
+
return (spec.CandidateSources ?? []).map((s) => ({ Kind: s.Kind, Ref: s.Ref }));
|
|
43
|
+
}
|
|
44
|
+
/** Leakage guard: deny every field the plan marked `exclude`, plus the dominance threshold. */
|
|
45
|
+
function buildLeakageGuard(spec) {
|
|
46
|
+
const denyFields = (spec.LeakageNotes ?? []).filter((n) => n.Action === 'exclude').map((n) => n.Field);
|
|
47
|
+
return { DenyFields: denyFields, SingleFeatureDominanceThreshold: DEFAULT_DOMINANCE_THRESHOLD };
|
|
48
|
+
}
|
|
49
|
+
/** Validation strategy straight from the plan (LockedHoldoutFraction is always carried). */
|
|
50
|
+
function buildValidation(spec) {
|
|
51
|
+
const v = spec.ValidationStrategy;
|
|
52
|
+
return {
|
|
53
|
+
Strategy: v?.Strategy ?? 'holdout',
|
|
54
|
+
TestSize: v?.TestSize,
|
|
55
|
+
K: v?.K,
|
|
56
|
+
LockedHoldoutFraction: v?.LockedHoldoutFraction ?? 0.2,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Derive a concise pipeline name from the plan's goal (trim + cap length). */
|
|
60
|
+
function deriveName(goal) {
|
|
61
|
+
const trimmed = (goal ?? '').trim();
|
|
62
|
+
if (!trimmed)
|
|
63
|
+
return 'New prediction';
|
|
64
|
+
return trimmed.length <= 80 ? trimmed : `${trimmed.slice(0, 77)}…`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Deterministically translate an approved {@link ModelingPlanSpec} into the concrete pipeline
|
|
68
|
+
* configuration the builder will persist. Throws on a spec that can't yield a trainable pipeline
|
|
69
|
+
* (no target entity, no target variable, or no proposed algorithm) — the builder surfaces these as a
|
|
70
|
+
* clean failure rather than creating a broken pipeline.
|
|
71
|
+
*
|
|
72
|
+
* @param spec the approved modeling plan the agent accumulated.
|
|
73
|
+
* @returns the resolved {@link PipelineConfig}.
|
|
74
|
+
*/
|
|
75
|
+
export function modelingPlanToPipelineConfig(spec) {
|
|
76
|
+
const target = spec.TargetDefinition;
|
|
77
|
+
if (!target?.EntityName?.trim()) {
|
|
78
|
+
throw new Error('ModelingPlanSpec.TargetDefinition.EntityName is required to build a pipeline.');
|
|
79
|
+
}
|
|
80
|
+
if (!target.TargetVariable?.trim()) {
|
|
81
|
+
throw new Error('ModelingPlanSpec.TargetDefinition.TargetVariable is required to build a pipeline.');
|
|
82
|
+
}
|
|
83
|
+
const experiment = chooseExperiment(spec);
|
|
84
|
+
if (!experiment?.AlgorithmName?.trim()) {
|
|
85
|
+
throw new Error('ModelingPlanSpec needs at least one ProposedExperiment with an AlgorithmName to build a pipeline.');
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
name: deriveName(spec.Goal),
|
|
89
|
+
description: spec.Goal?.trim() || 'Created by the Predictive Studio Agent.',
|
|
90
|
+
targetEntityName: target.EntityName.trim(),
|
|
91
|
+
targetVariable: target.TargetVariable.trim(),
|
|
92
|
+
problemType: target.ProblemType,
|
|
93
|
+
algorithmName: experiment.AlgorithmName.trim(),
|
|
94
|
+
sourceBindings: buildSourceBindings(spec),
|
|
95
|
+
featureSteps: buildFeatureSteps(spec, experiment.FeatureSet ?? []),
|
|
96
|
+
asOf: target.AsOfStrategy ?? { Mode: 'none' },
|
|
97
|
+
leakageGuard: buildLeakageGuard(spec),
|
|
98
|
+
validation: buildValidation(spec),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=modeling-plan-to-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modeling-plan-to-pipeline.js","sourceRoot":"","sources":["../../src/agent/modeling-plan-to-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuCH,oFAAoF;AACpF,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC,mGAAmG;AACnG,SAAS,gBAAgB,CAAC,IAAsB;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC;IACnD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,8GAA8G;AAC9G,SAAS,iBAAiB,CAAC,IAAsB,EAAE,UAAoB;IACrE,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC;IACzC,gGAAgG;IAChG,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC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,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACvG,CAAC;IACD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,mGAAmG,CAAC,CAAC;IACvH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,yCAAyC;QAC3E,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAC1C,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAC5C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,IAAI,EAAE;QAC9C,cAAc,EAAE,mBAAmB,CAAC,IAAI,CAAC;QACzC,YAAY,EAAE,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC;QAClE,IAAI,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;QAC7C,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC;QACrC,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/pipeline-builder-agent
|
|
3
|
+
*
|
|
4
|
+
* The Predictive Studio Agent's **code sub-agent** — the framework wrapper around the deterministic
|
|
5
|
+
* {@link PredictiveStudioPipelineBuilder}. It mirrors Database Designer's `DatabaseDesignerSchemaBuilder`
|
|
6
|
+
* and Agent Manager's builder: a `BaseAgent` whose `executeAgentInternal` runs **once, in pure code
|
|
7
|
+
* (no LLM)**, reads the approved {@link ModelingPlanSpec} off the agent payload, builds the pipeline +
|
|
8
|
+
* trains + publishes-gated-on-trust, and writes the outcome back to the payload. The conversational
|
|
9
|
+
* sub-agents (Goal Analyst / Data Scout / Experiment Designer) accumulate the plan; THIS agent commits
|
|
10
|
+
* it to metadata, so the structure created is type-safe and deterministic — never LLM-emitted.
|
|
11
|
+
*
|
|
12
|
+
* Registered by DriverClass `'PredictiveStudioPipelineBuilderAgent'` so the Model Development Agent's
|
|
13
|
+
* metadata can route to it after the user approves.
|
|
14
|
+
*/
|
|
15
|
+
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
16
|
+
import type { ExecuteAgentParams, AgentConfiguration, BaseAgentNextStep } from '@memberjunction/ai-core-plus';
|
|
17
|
+
import type { ModelingPlanSpec, TrustGrade } from '@memberjunction/predictive-studio-core';
|
|
18
|
+
import { PredictiveStudioPipelineBuilder, type BuildPredictionResult } from './pipeline-builder.js';
|
|
19
|
+
/** The compact, payload-safe outcome the builder writes back so the agent can narrate the result. */
|
|
20
|
+
export interface PredictiveStudioBuildOutcome {
|
|
21
|
+
success: boolean;
|
|
22
|
+
pipelineId?: string;
|
|
23
|
+
modelId?: string;
|
|
24
|
+
trustGrade?: TrustGrade;
|
|
25
|
+
trustOneLiner?: string;
|
|
26
|
+
published: boolean;
|
|
27
|
+
/** When not published, the plain reason (trust gate / leakage); else null. */
|
|
28
|
+
heldReason: string | null;
|
|
29
|
+
/** A clean error message when the build failed; else null. */
|
|
30
|
+
errorMessage: string | null;
|
|
31
|
+
}
|
|
32
|
+
/** The agent payload = the modeling plan the conversation accumulated, plus the builder's outcome. */
|
|
33
|
+
export interface PredictiveStudioBuilderPayload extends ModelingPlanSpec {
|
|
34
|
+
BuildResult?: PredictiveStudioBuildOutcome;
|
|
35
|
+
}
|
|
36
|
+
/** Project the rich {@link BuildPredictionResult} into the compact, payload-safe outcome (pure → testable). */
|
|
37
|
+
export declare function summarizeBuildResult(result: BuildPredictionResult): PredictiveStudioBuildOutcome;
|
|
38
|
+
/** A plain, user-facing sentence describing what the build did (for the agent's reasoning/message). */
|
|
39
|
+
export declare function buildOutcomeMessage(o: PredictiveStudioBuildOutcome): string;
|
|
40
|
+
export declare class PredictiveStudioPipelineBuilderAgent extends BaseAgent {
|
|
41
|
+
/**
|
|
42
|
+
* Run the deterministic build once. Reads the approved plan off `params.payload`, builds the
|
|
43
|
+
* pipeline + trains + publishes-gated-on-trust, writes the outcome to the payload, and terminates
|
|
44
|
+
* the sub-agent with Success (build ran — even when the model is held, that's a successful run with
|
|
45
|
+
* a held outcome) or Failed (the build itself errored).
|
|
46
|
+
*/
|
|
47
|
+
protected executeAgentInternal<P = PredictiveStudioBuilderPayload>(params: ExecuteAgentParams, _config: AgentConfiguration): Promise<{
|
|
48
|
+
finalStep: BaseAgentNextStep<P>;
|
|
49
|
+
stepCount: number;
|
|
50
|
+
}>;
|
|
51
|
+
/** Builder seam — overridden in unit tests to inject a stub (no DB / sidecar). */
|
|
52
|
+
protected createBuilder(): PredictiveStudioPipelineBuilder;
|
|
53
|
+
/** Shape a terminal code-agent step (no chat loop), mirroring the Database Designer base code agent. */
|
|
54
|
+
private codeStep;
|
|
55
|
+
}
|
|
56
|
+
/** Tree-shaking anchor — call from a manifest/loader so the @RegisterClass side effect survives bundling. */
|
|
57
|
+
export declare function LoadPredictiveStudioPipelineBuilderAgent(): void;
|
|
58
|
+
//# sourceMappingURL=pipeline-builder-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-builder-agent.d.ts","sourceRoot":"","sources":["../../src/agent/pipeline-builder-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wCA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