@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,101 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
18
|
+
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;
|
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
20
|
+
};
|
|
21
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
22
|
+
import { LogError } from '@memberjunction/core';
|
|
23
|
+
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
24
|
+
import { PredictiveStudioPipelineBuilder } from './pipeline-builder.js';
|
|
25
|
+
/** Project the rich {@link BuildPredictionResult} into the compact, payload-safe outcome (pure → testable). */
|
|
26
|
+
export function summarizeBuildResult(result) {
|
|
27
|
+
return {
|
|
28
|
+
success: result.success,
|
|
29
|
+
pipelineId: result.pipelineId,
|
|
30
|
+
modelId: result.modelId,
|
|
31
|
+
trustGrade: result.trust?.grade,
|
|
32
|
+
trustOneLiner: result.trust?.oneLiner,
|
|
33
|
+
published: result.published,
|
|
34
|
+
heldReason: result.heldReason,
|
|
35
|
+
errorMessage: result.errorMessage,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** A plain, user-facing sentence describing what the build did (for the agent's reasoning/message). */
|
|
39
|
+
export function buildOutcomeMessage(o) {
|
|
40
|
+
if (!o.success)
|
|
41
|
+
return `I couldn't build the prediction: ${o.errorMessage ?? 'unknown error'}.`;
|
|
42
|
+
if (o.published)
|
|
43
|
+
return `Done — I built and published your prediction (trust: ${o.trustGrade}). It's now in your Predictions.`;
|
|
44
|
+
return `I built and trained the prediction, but I'm holding it back: ${o.heldReason ?? 'it needs review before it can be published.'}`;
|
|
45
|
+
}
|
|
46
|
+
let PredictiveStudioPipelineBuilderAgent = class PredictiveStudioPipelineBuilderAgent extends BaseAgent {
|
|
47
|
+
/**
|
|
48
|
+
* Run the deterministic build once. Reads the approved plan off `params.payload`, builds the
|
|
49
|
+
* pipeline + trains + publishes-gated-on-trust, writes the outcome to the payload, and terminates
|
|
50
|
+
* the sub-agent with Success (build ran — even when the model is held, that's a successful run with
|
|
51
|
+
* a held outcome) or Failed (the build itself errored).
|
|
52
|
+
*/
|
|
53
|
+
async executeAgentInternal(params, _config) {
|
|
54
|
+
const payload = (params.payload ?? {});
|
|
55
|
+
const user = params.contextUser;
|
|
56
|
+
if (!user) {
|
|
57
|
+
return this.codeStep('Failed', payload, 'No context user — cannot build the pipeline.');
|
|
58
|
+
}
|
|
59
|
+
const provider = this.ProviderToUse;
|
|
60
|
+
if (!provider) {
|
|
61
|
+
return this.codeStep('Failed', payload, 'No metadata provider available — cannot build the pipeline.');
|
|
62
|
+
}
|
|
63
|
+
let result;
|
|
64
|
+
try {
|
|
65
|
+
result = await this.createBuilder().build({ spec: payload, provider, user });
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
69
|
+
LogError(`PredictiveStudioPipelineBuilderAgent: build threw: ${errorMessage}`);
|
|
70
|
+
result = { success: false, published: false, leakageFlagged: false, heldReason: null, errorMessage };
|
|
71
|
+
}
|
|
72
|
+
const outcome = summarizeBuildResult(result);
|
|
73
|
+
const newPayload = { ...payload, BuildResult: outcome };
|
|
74
|
+
const message = buildOutcomeMessage(outcome);
|
|
75
|
+
// A failed BUILD (couldn't create/train) is a Failed step; a successful run whose model is merely
|
|
76
|
+
// HELD (trust gate / leakage) is still a Success step — the build ran and the gate did its job.
|
|
77
|
+
return this.codeStep(outcome.success ? 'Success' : 'Failed', newPayload, message);
|
|
78
|
+
}
|
|
79
|
+
/** Builder seam — overridden in unit tests to inject a stub (no DB / sidecar). */
|
|
80
|
+
createBuilder() {
|
|
81
|
+
return new PredictiveStudioPipelineBuilder();
|
|
82
|
+
}
|
|
83
|
+
/** Shape a terminal code-agent step (no chat loop), mirroring the Database Designer base code agent. */
|
|
84
|
+
codeStep(step, newPayload, reasoning) {
|
|
85
|
+
const finalStep = { terminate: true, step, reasoning, newPayload };
|
|
86
|
+
if (step === 'Failed') {
|
|
87
|
+
finalStep.message = reasoning;
|
|
88
|
+
finalStep.errorMessage = reasoning;
|
|
89
|
+
}
|
|
90
|
+
return { finalStep, stepCount: 1 };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
PredictiveStudioPipelineBuilderAgent = __decorate([
|
|
94
|
+
RegisterClass(BaseAgent, 'PredictiveStudioPipelineBuilderAgent')
|
|
95
|
+
], PredictiveStudioPipelineBuilderAgent);
|
|
96
|
+
export { PredictiveStudioPipelineBuilderAgent };
|
|
97
|
+
/** Tree-shaking anchor — call from a manifest/loader so the @RegisterClass side effect survives bundling. */
|
|
98
|
+
export function LoadPredictiveStudioPipelineBuilderAgent() {
|
|
99
|
+
/* no-op */
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=pipeline-builder-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-builder-agent.js","sourceRoot":"","sources":["../../src/agent/pipeline-builder-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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AAO,IAAI,+BAA+B,EAAE,CAAC;IAC/C,CAAC;IAED,wGAAwG;IAChG,QAAQ,CAAI,IAA0B,EAAE,UAAa,EAAE,SAAiB;QAC9E,MAAM,SAAS,GAAyB,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAA0B,CAAC;QACjH,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrB,SAAyD,CAAC,OAAO,GAAG,SAAS,CAAC;YAC9E,SAAyD,CAAC,YAAY,GAAG,SAAS,CAAC;QACtF,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACrC,CAAC;CACF,CAAA;AApDY,oCAAoC;IADhD,aAAa,CAAC,SAAS,EAAE,sCAAsC,CAAC;GACpD,oCAAoC,CAoDhD;;AAED,6GAA6G;AAC7G,MAAM,UAAU,wCAAwC;IACtD,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/pipeline-builder
|
|
3
|
+
*
|
|
4
|
+
* The **deterministic builder** behind the Predictive Studio Agent — the Predictive Studio analogue
|
|
5
|
+
* of Database Designer's schema builder and Agent Manager's `AgentSpecSync`. It takes an approved,
|
|
6
|
+
* strongly-typed {@link ModelingPlanSpec} and, in pure code (NO LLM), crafts the actual metadata:
|
|
7
|
+
* creates the `MJ: ML Training Pipelines` row, kicks off training, then **publishes the model only
|
|
8
|
+
* if the trust verdict clears the bar** — the same `deriveTrustVerdict` gate the business UI uses, so
|
|
9
|
+
* a coin-flip / unmeasured / leakage-flagged model is never silently published into the catalog.
|
|
10
|
+
*
|
|
11
|
+
* Used by the agent's builder sub-agent AND directly callable from a headless script/test, so the
|
|
12
|
+
* "build a new prediction" path is verifiable without the full LLM loop.
|
|
13
|
+
*/
|
|
14
|
+
import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
|
|
15
|
+
import { type ModelingPlanSpec, type TrustVerdict } from '@memberjunction/predictive-studio-core';
|
|
16
|
+
/** Inputs for {@link PredictiveStudioPipelineBuilder.build}. */
|
|
17
|
+
export interface BuildPredictionInput {
|
|
18
|
+
/** The approved modeling plan the agent accumulated. */
|
|
19
|
+
spec: ModelingPlanSpec;
|
|
20
|
+
/** The owning provider (multi-provider correctness). */
|
|
21
|
+
provider: IMetadataProvider;
|
|
22
|
+
/** The acting user (isolation/audit). */
|
|
23
|
+
user: UserInfo;
|
|
24
|
+
/** Publish the trained model when the trust verdict clears the bar. Default true. */
|
|
25
|
+
autoPublish?: boolean;
|
|
26
|
+
/** Sidecar version marker recorded in lineage. */
|
|
27
|
+
sidecarVersion?: string;
|
|
28
|
+
}
|
|
29
|
+
/** The outcome of building a prediction from a plan. */
|
|
30
|
+
export interface BuildPredictionResult {
|
|
31
|
+
/** Whether the build (pipeline create + train) succeeded. */
|
|
32
|
+
success: boolean;
|
|
33
|
+
/** The created `MJ: ML Training Pipelines` id (present once the pipeline is created). */
|
|
34
|
+
pipelineId?: string;
|
|
35
|
+
/** The trained `MJ: ML Models` id (present once training completes). */
|
|
36
|
+
modelId?: string;
|
|
37
|
+
/** The plain-language trust verdict for the trained model. */
|
|
38
|
+
trust?: TrustVerdict;
|
|
39
|
+
/** Whether the model was published into the business catalog. */
|
|
40
|
+
published: boolean;
|
|
41
|
+
/** Whether training flagged a leakage warning (held for analyst review). */
|
|
42
|
+
leakageFlagged: boolean;
|
|
43
|
+
/** When not published, the plain reason (trust gate or leakage); else null. */
|
|
44
|
+
heldReason: string | null;
|
|
45
|
+
/** A clean error message when the build failed; else null. */
|
|
46
|
+
errorMessage: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** Deterministic builder: approved {@link ModelingPlanSpec} → pipeline + trained (+ maybe published) model. */
|
|
49
|
+
export declare class PredictiveStudioPipelineBuilder {
|
|
50
|
+
/**
|
|
51
|
+
* Build a prediction from an approved plan: create the pipeline, train, and publish if the trust
|
|
52
|
+
* verdict clears the bar. Never throws — returns a typed result with `success`/`errorMessage`.
|
|
53
|
+
*/
|
|
54
|
+
build(input: BuildPredictionInput): Promise<BuildPredictionResult>;
|
|
55
|
+
/** Create + save the `MJ: ML Training Pipelines` row from the resolved config. */
|
|
56
|
+
private createPipeline;
|
|
57
|
+
/** Resolve the training-unit entity name to its ID via the provider's metadata (case-insensitive). */
|
|
58
|
+
private resolveTargetEntityId;
|
|
59
|
+
/** Resolve an algorithm NAME to its `MJ: ML Algorithms` id. Throws if the algorithm doesn't exist. */
|
|
60
|
+
private resolveAlgorithmId;
|
|
61
|
+
/**
|
|
62
|
+
* Publish the trained model into the business catalog ONLY if the trust verdict clears the bar and
|
|
63
|
+
* training wasn't leakage-flagged. Otherwise leave it Draft and return the plain held-reason.
|
|
64
|
+
*/
|
|
65
|
+
private maybePublish;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=pipeline-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-builder.d.ts","sourceRoot":"","sources":["../../src/agent/pipeline-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,KAAK,gBAAgB,EAAsB,KAAK,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAKtH,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,IAAI,EAAE,gBAAgB,CAAC;IACvB,wDAAwD;IACxD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,yCAAyC;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,qFAAqF;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,cAAc,EAAE,OAAO,CAAC;IACxB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,+GAA+G;AAC/G,qBAAa,+BAA+B;IAC1C;;;OAGG;IACU,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA4B/E,kFAAkF;YACpE,cAAc;IAyB5B,sGAAsG;IACtG,OAAO,CAAC,qBAAqB;IAQ7B,sGAAsG;YACxF,kBAAkB;IAahC;;;OAGG;YACW,YAAY;CAqB3B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent/pipeline-builder
|
|
3
|
+
*
|
|
4
|
+
* The **deterministic builder** behind the Predictive Studio Agent — the Predictive Studio analogue
|
|
5
|
+
* of Database Designer's schema builder and Agent Manager's `AgentSpecSync`. It takes an approved,
|
|
6
|
+
* strongly-typed {@link ModelingPlanSpec} and, in pure code (NO LLM), crafts the actual metadata:
|
|
7
|
+
* creates the `MJ: ML Training Pipelines` row, kicks off training, then **publishes the model only
|
|
8
|
+
* if the trust verdict clears the bar** — the same `deriveTrustVerdict` gate the business UI uses, so
|
|
9
|
+
* a coin-flip / unmeasured / leakage-flagged model is never silently published into the catalog.
|
|
10
|
+
*
|
|
11
|
+
* Used by the agent's builder sub-agent AND directly callable from a headless script/test, so the
|
|
12
|
+
* "build a new prediction" path is verifiable without the full LLM loop.
|
|
13
|
+
*/
|
|
14
|
+
import { RunView, LogError } from '@memberjunction/core';
|
|
15
|
+
import { deriveTrustVerdict } from '@memberjunction/predictive-studio-core';
|
|
16
|
+
import { modelingPlanToPipelineConfig } from './modeling-plan-to-pipeline.js';
|
|
17
|
+
import { trainModelViaEngine, wasTrainingLeakageFlagged } from '../operations/delegation.js';
|
|
18
|
+
/** Deterministic builder: approved {@link ModelingPlanSpec} → pipeline + trained (+ maybe published) model. */
|
|
19
|
+
export class PredictiveStudioPipelineBuilder {
|
|
20
|
+
/**
|
|
21
|
+
* Build a prediction from an approved plan: create the pipeline, train, and publish if the trust
|
|
22
|
+
* verdict clears the bar. Never throws — returns a typed result with `success`/`errorMessage`.
|
|
23
|
+
*/
|
|
24
|
+
async build(input) {
|
|
25
|
+
const { spec, provider, user, autoPublish = true, sidecarVersion = 'predictive-studio-agent' } = input;
|
|
26
|
+
try {
|
|
27
|
+
const config = modelingPlanToPipelineConfig(spec);
|
|
28
|
+
const pipeline = await this.createPipeline(config, provider, user);
|
|
29
|
+
const trainResult = await trainModelViaEngine({ pipelineId: pipeline.ID, sidecarVersion }, provider, user);
|
|
30
|
+
const model = trainResult.model;
|
|
31
|
+
const trust = deriveTrustVerdict(model);
|
|
32
|
+
const leakageFlagged = wasTrainingLeakageFlagged(trainResult);
|
|
33
|
+
const { published, heldReason } = await this.maybePublish(model, trust, leakageFlagged, autoPublish);
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
pipelineId: pipeline.ID,
|
|
37
|
+
modelId: model.ID,
|
|
38
|
+
trust,
|
|
39
|
+
published,
|
|
40
|
+
leakageFlagged,
|
|
41
|
+
heldReason,
|
|
42
|
+
errorMessage: null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
47
|
+
LogError(`PredictiveStudioPipelineBuilder.build failed: ${errorMessage}`);
|
|
48
|
+
return { success: false, published: false, leakageFlagged: false, heldReason: null, errorMessage };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Create + save the `MJ: ML Training Pipelines` row from the resolved config. */
|
|
52
|
+
async createPipeline(config, provider, user) {
|
|
53
|
+
const targetEntityId = this.resolveTargetEntityId(config.targetEntityName, provider);
|
|
54
|
+
const algorithmId = await this.resolveAlgorithmId(config.algorithmName, provider, user);
|
|
55
|
+
const pipeline = await provider.GetEntityObject('MJ: ML Training Pipelines', user);
|
|
56
|
+
pipeline.NewRecord();
|
|
57
|
+
pipeline.Name = config.name;
|
|
58
|
+
pipeline.Description = config.description;
|
|
59
|
+
pipeline.Version = 1;
|
|
60
|
+
pipeline.Status = 'Draft';
|
|
61
|
+
pipeline.TargetEntityID = targetEntityId;
|
|
62
|
+
pipeline.TargetVariable = config.targetVariable;
|
|
63
|
+
pipeline.ProblemType = config.problemType;
|
|
64
|
+
pipeline.AlgorithmID = algorithmId;
|
|
65
|
+
pipeline.SourceBindings = JSON.stringify(config.sourceBindings);
|
|
66
|
+
pipeline.FeatureSteps = JSON.stringify(config.featureSteps);
|
|
67
|
+
pipeline.AsOfStrategy = JSON.stringify(config.asOf);
|
|
68
|
+
pipeline.LeakageGuard = JSON.stringify(config.leakageGuard);
|
|
69
|
+
pipeline.ValidationStrategy = JSON.stringify(config.validation);
|
|
70
|
+
if (!(await pipeline.Save())) {
|
|
71
|
+
throw new Error(`Failed to create training pipeline: ${pipeline.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
72
|
+
}
|
|
73
|
+
return pipeline;
|
|
74
|
+
}
|
|
75
|
+
/** Resolve the training-unit entity name to its ID via the provider's metadata (case-insensitive). */
|
|
76
|
+
resolveTargetEntityId(entityName, provider) {
|
|
77
|
+
const entity = provider.EntityByName(entityName);
|
|
78
|
+
if (!entity) {
|
|
79
|
+
throw new Error(`Target entity '${entityName}' was not found in metadata. The plan must reference a real entity.`);
|
|
80
|
+
}
|
|
81
|
+
return entity.ID;
|
|
82
|
+
}
|
|
83
|
+
/** Resolve an algorithm NAME to its `MJ: ML Algorithms` id. Throws if the algorithm doesn't exist. */
|
|
84
|
+
async resolveAlgorithmId(algorithmName, provider, user) {
|
|
85
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
86
|
+
const res = await rv.RunView({ EntityName: 'MJ: ML Algorithms', ExtraFilter: `Name='${algorithmName.replace(/'/g, "''")}'`, Fields: ['ID'], ResultType: 'simple', MaxRows: 1 }, user);
|
|
87
|
+
const id = res.Success ? res.Results?.[0]?.ID : undefined;
|
|
88
|
+
if (!id) {
|
|
89
|
+
throw new Error(`Algorithm '${algorithmName}' was not found in MJ: ML Algorithms. The plan must propose a registered algorithm.`);
|
|
90
|
+
}
|
|
91
|
+
return id;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Publish the trained model into the business catalog ONLY if the trust verdict clears the bar and
|
|
95
|
+
* training wasn't leakage-flagged. Otherwise leave it Draft and return the plain held-reason.
|
|
96
|
+
*/
|
|
97
|
+
async maybePublish(model, trust, leakageFlagged, autoPublish) {
|
|
98
|
+
if (!autoPublish) {
|
|
99
|
+
return { published: false, heldReason: 'Not published — auto-publish was off; review and publish when ready.' };
|
|
100
|
+
}
|
|
101
|
+
if (leakageFlagged) {
|
|
102
|
+
return { published: false, heldReason: 'Held for analyst review — training flagged a possible data-leakage issue.' };
|
|
103
|
+
}
|
|
104
|
+
if (!trust.canAct) {
|
|
105
|
+
return { published: false, heldReason: trust.gateReason ?? 'Held — this prediction is not reliable enough to publish yet.' };
|
|
106
|
+
}
|
|
107
|
+
model.Status = 'Published';
|
|
108
|
+
if (!(await model.Save())) {
|
|
109
|
+
throw new Error(`Trained model could not be published: ${model.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
110
|
+
}
|
|
111
|
+
return { published: true, heldReason: null };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=pipeline-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-builder.js","sourceRoot":"","sources":["../../src/agent/pipeline-builder.ts"],"names":[],"mappings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CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module experiment/concurrency
|
|
3
|
+
*
|
|
4
|
+
* A tiny dependency-free bounded-concurrency pool used to run a wave of
|
|
5
|
+
* iterations with at most N in flight (plan §8.3 — "bounded concurrency"). The
|
|
6
|
+
* production engine composes onto Record Set Processing's pool for budget/audit;
|
|
7
|
+
* this inline pool keeps the orchestrator self-contained and deterministic for
|
|
8
|
+
* unit tests (no new dependency, no `p-limit`).
|
|
9
|
+
*
|
|
10
|
+
* Results are returned in the SAME ORDER as the input tasks regardless of
|
|
11
|
+
* completion order, so downstream leaderboard/prune logic is deterministic.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Optional controls for {@link runBounded}.
|
|
15
|
+
*/
|
|
16
|
+
export interface RunBoundedOptions {
|
|
17
|
+
/**
|
|
18
|
+
* A predicate consulted by each worker BEFORE it pulls the next task. When it
|
|
19
|
+
* returns `true`, workers stop dispatching new tasks (already-in-flight tasks
|
|
20
|
+
* still finish). Used to stop the wave the instant a budget bound trips so no
|
|
21
|
+
* extra iteration is ever dispatched (plan §8.4 — no overrun). Tasks that are
|
|
22
|
+
* never dispatched leave their result slot `undefined`.
|
|
23
|
+
*/
|
|
24
|
+
shouldStop?: () => boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run `tasks` with at most `limit` executing concurrently, preserving input
|
|
28
|
+
* order in the returned results.
|
|
29
|
+
*
|
|
30
|
+
* When `options.shouldStop` is supplied it is evaluated by each worker before it
|
|
31
|
+
* claims its next task; once it returns `true` no further tasks are dispatched
|
|
32
|
+
* (in-flight tasks still complete) and their slots stay `undefined`.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam T the task result type
|
|
35
|
+
* @param tasks the task thunks to run
|
|
36
|
+
* @param limit the maximum number in flight (coerced to ≥ 1)
|
|
37
|
+
* @param options optional controls (e.g. a `shouldStop` budget predicate)
|
|
38
|
+
* @returns the results in the same order as `tasks` (`undefined` for un-dispatched slots)
|
|
39
|
+
*/
|
|
40
|
+
export declare function runBounded<T>(tasks: Array<() => Promise<T>>, limit: number, options?: RunBoundedOptions): Promise<Array<T | undefined>>;
|
|
41
|
+
//# sourceMappingURL=concurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../../src/experiment/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,KAAK,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAC9B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CA4B/B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module experiment/concurrency
|
|
3
|
+
*
|
|
4
|
+
* A tiny dependency-free bounded-concurrency pool used to run a wave of
|
|
5
|
+
* iterations with at most N in flight (plan §8.3 — "bounded concurrency"). The
|
|
6
|
+
* production engine composes onto Record Set Processing's pool for budget/audit;
|
|
7
|
+
* this inline pool keeps the orchestrator self-contained and deterministic for
|
|
8
|
+
* unit tests (no new dependency, no `p-limit`).
|
|
9
|
+
*
|
|
10
|
+
* Results are returned in the SAME ORDER as the input tasks regardless of
|
|
11
|
+
* completion order, so downstream leaderboard/prune logic is deterministic.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Run `tasks` with at most `limit` executing concurrently, preserving input
|
|
15
|
+
* order in the returned results.
|
|
16
|
+
*
|
|
17
|
+
* When `options.shouldStop` is supplied it is evaluated by each worker before it
|
|
18
|
+
* claims its next task; once it returns `true` no further tasks are dispatched
|
|
19
|
+
* (in-flight tasks still complete) and their slots stay `undefined`.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam T the task result type
|
|
22
|
+
* @param tasks the task thunks to run
|
|
23
|
+
* @param limit the maximum number in flight (coerced to ≥ 1)
|
|
24
|
+
* @param options optional controls (e.g. a `shouldStop` budget predicate)
|
|
25
|
+
* @returns the results in the same order as `tasks` (`undefined` for un-dispatched slots)
|
|
26
|
+
*/
|
|
27
|
+
export async function runBounded(tasks, limit, options = {}) {
|
|
28
|
+
const max = Math.max(1, Math.floor(limit));
|
|
29
|
+
const results = new Array(tasks.length);
|
|
30
|
+
const { shouldStop } = options;
|
|
31
|
+
let nextIndex = 0;
|
|
32
|
+
async function worker() {
|
|
33
|
+
while (true) {
|
|
34
|
+
// Consult the stop predicate BEFORE claiming a task so a budget bound that
|
|
35
|
+
// tripped mid-wave prevents any further dispatch.
|
|
36
|
+
if (shouldStop && shouldStop()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const current = nextIndex++;
|
|
40
|
+
if (current >= tasks.length) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
results[current] = await tasks[current]();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const workerCount = Math.min(max, tasks.length);
|
|
47
|
+
const workers = [];
|
|
48
|
+
for (let i = 0; i < workerCount; i++) {
|
|
49
|
+
workers.push(worker());
|
|
50
|
+
}
|
|
51
|
+
await Promise.all(workers);
|
|
52
|
+
return results;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.js","sourceRoot":"","sources":["../../src/experiment/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAA8B,EAC9B,KAAa,EACb,UAA6B,EAAE;IAE/B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAyB,IAAI,KAAK,CAAgB,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,UAAU,MAAM;QACnB,OAAO,IAAI,EAAE,CAAC;YACZ,2EAA2E;YAC3E,kDAAkD;YAClD,IAAI,UAAU,IAAI,UAAU,EAAE,EAAE,CAAC;gBAC/B,OAAO;YACT,CAAC;YACD,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;YAC5B,IAAI,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO;YACT,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,OAAO,GAAyB,EAAE,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module experiment/experiment-orchestrator
|
|
3
|
+
*
|
|
4
|
+
* The **ExperimentOrchestrator** — Predictive Studio's deterministic
|
|
5
|
+
* execution-phase plan executor (plan §8.3 / §8.4 / §9.1). Given an
|
|
6
|
+
* **already-approved** {@link ModelingPlanSpec}, it runs the plan's
|
|
7
|
+
* `ProposedExperiments` as **waves** with bounded concurrency, maintaining a
|
|
8
|
+
* leaderboard, pruning dominated branches, and gating on the session `Budget`.
|
|
9
|
+
*
|
|
10
|
+
* ## Session lifecycle (§4.5 / §8.3)
|
|
11
|
+
* `Experiment` (durable definition) → `Experiment Session` (one execution,
|
|
12
|
+
* Status `Planning → AwaitingApproval → Running → Paused → Completed/Cancelled`)
|
|
13
|
+
* → N `Experiment Session Iterations` (the leaderboard unit, each with an
|
|
14
|
+
* `ML Training Run` leaf). The orchestrator receives an approved plan, so it
|
|
15
|
+
* moves the session `Running` immediately (the approval gate is the agent's
|
|
16
|
+
* job) and finalizes `Completed` or — on a budget bound — pauses cleanly
|
|
17
|
+
* (`Paused`) rather than overrun.
|
|
18
|
+
*
|
|
19
|
+
* ## Deterministic wave loop (§8.3 — the core)
|
|
20
|
+
* ```text
|
|
21
|
+
* generate wave → train wave (bounded concurrency) → evaluate → update
|
|
22
|
+
* leaderboard → prune → budget-gate → decide next wave
|
|
23
|
+
* ```
|
|
24
|
+
* For each experiment in a wave the orchestrator creates an iteration
|
|
25
|
+
* (`Pending → Running`), trains it via the injected {@link IExperimentTrainer}
|
|
26
|
+
* (→ model + run + normalized Score), links the run to the iteration, scores the
|
|
27
|
+
* iteration, then updates the leaderboard. After each wave it prunes
|
|
28
|
+
* unpromising branches (top-K / relative threshold), checks the budget, and asks
|
|
29
|
+
* the {@link IWaveStrategist} for the next wave.
|
|
30
|
+
*
|
|
31
|
+
* ## Adaptive "what-next" seam (§9.1)
|
|
32
|
+
* The next wave comes from {@link IWaveStrategist.proposeNextWave}. The default
|
|
33
|
+
* ({@link PlanOrderWaveStrategist}) is fully deterministic (iterate the plan in
|
|
34
|
+
* priority order, in waves); an LLM-backed strategist can be injected to swap in
|
|
35
|
+
* "given these results, what to try next" — the deterministic loop is unchanged.
|
|
36
|
+
*
|
|
37
|
+
* Every external dependency is injected ({@link ExperimentDeps}) so the engine
|
|
38
|
+
* is unit-testable with no live database, no live sidecar, and no real clock.
|
|
39
|
+
*/
|
|
40
|
+
import type { ModelingPlanSpec } from '@memberjunction/predictive-studio-core';
|
|
41
|
+
import { type ExperimentDeps, type ExperimentRunOptions, type ExperimentSessionResult } from './types.js';
|
|
42
|
+
/**
|
|
43
|
+
* The deterministic experiment orchestrator. Stateless across calls; construct
|
|
44
|
+
* once and reuse. All dependencies are supplied per call via
|
|
45
|
+
* {@link ExperimentDeps}.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ExperimentOrchestrator {
|
|
48
|
+
/**
|
|
49
|
+
* Execute an approved modeling plan for a fresh experiment session.
|
|
50
|
+
*
|
|
51
|
+
* @param plan the **approved** modeling plan (the approval gate is the agent's job)
|
|
52
|
+
* @param deps the injected dependency bundle (entity factory, trainer, clock, strategist)
|
|
53
|
+
* @param options optional run tunables (concurrency, prune rules, budget override)
|
|
54
|
+
* @returns the experiment, session, iterations, final leaderboard, best model, and stop reason
|
|
55
|
+
*/
|
|
56
|
+
runSession(plan: ModelingPlanSpec, deps: ExperimentDeps, options?: ExperimentRunOptions): Promise<ExperimentSessionResult>;
|
|
57
|
+
/** Guard: the orchestrator only executes approved plans (§9.1). */
|
|
58
|
+
private assertApproved;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve (or create) the durable `MJ: Experiments` definition. When
|
|
61
|
+
* `options.experimentID` is supplied, the caller already created one; otherwise
|
|
62
|
+
* a new Active definition is created from the plan.
|
|
63
|
+
*/
|
|
64
|
+
private resolveExperiment;
|
|
65
|
+
/** Budget = explicit override, else the plan's `ProposedBudget` (both optional). */
|
|
66
|
+
private resolveBudget;
|
|
67
|
+
/**
|
|
68
|
+
* Create the `MJ: Experiment Sessions` row carrying the approved plan, budget,
|
|
69
|
+
* and (optional) agent run. The session moves straight to `Running` (approval
|
|
70
|
+
* already happened, §9.1).
|
|
71
|
+
*/
|
|
72
|
+
private createSession;
|
|
73
|
+
/** Ask the strategist for the next wave (the injectable "what-next" seam, §9.1). */
|
|
74
|
+
private nextWave;
|
|
75
|
+
/**
|
|
76
|
+
* Run a single wave: create + train its iterations with bounded concurrency,
|
|
77
|
+
* link each run to its iteration, score the iteration, and fold results into
|
|
78
|
+
* the leaderboard. Budget is re-checked per-iteration so the session pauses at
|
|
79
|
+
* the exact bound (no overrun).
|
|
80
|
+
*/
|
|
81
|
+
private runWave;
|
|
82
|
+
/** Create a `Pending` iteration row for an experiment, then mark it `Running`. */
|
|
83
|
+
private createIteration;
|
|
84
|
+
/**
|
|
85
|
+
* Train one iteration: mark it `Running`, call the trainer, link the run to the
|
|
86
|
+
* iteration, set the normalized Score + costs, and mark it `Completed` (or
|
|
87
|
+
* `Failed`). Returns a small outcome record for leaderboard/budget folding.
|
|
88
|
+
*/
|
|
89
|
+
private trainIteration;
|
|
90
|
+
/** Record a failed iteration (best-effort — never masks the loop's progress). */
|
|
91
|
+
private failIteration;
|
|
92
|
+
/**
|
|
93
|
+
* Prune dominated branches after a wave (§8.3). Iterations dropped from the
|
|
94
|
+
* leaderboard by the top-K / relative-threshold rules are marked `Pruned` with
|
|
95
|
+
* a recorded rationale; their entries leave the leaderboard so they aren't
|
|
96
|
+
* surfaced as winners.
|
|
97
|
+
*/
|
|
98
|
+
private applyPruning;
|
|
99
|
+
/**
|
|
100
|
+
* Mark a single iteration `Pruned` with a deterministic rationale and persist it.
|
|
101
|
+
* Returns whether the save succeeded so the caller can keep the leaderboard entry
|
|
102
|
+
* when the persist fails (never silently drop an iteration whose status didn't stick).
|
|
103
|
+
*/
|
|
104
|
+
private markPruned;
|
|
105
|
+
/** Gate before a wave starts — used to pause cleanly when a bound is already hit. */
|
|
106
|
+
private gateBeforeWave;
|
|
107
|
+
/**
|
|
108
|
+
* Trim a wave so it cannot exceed a `MaxRuns` budget — if only K more runs are
|
|
109
|
+
* allowed, only the first K experiments of the wave are dispatched (no
|
|
110
|
+
* overrun, §8.4).
|
|
111
|
+
*/
|
|
112
|
+
private trimWaveToBudget;
|
|
113
|
+
/**
|
|
114
|
+
* Evaluate the session budget (§8.4): MaxRuns, MaxComputeCost, and
|
|
115
|
+
* MaxWallclockMinutes (via the injected clock). Returns the first bound hit.
|
|
116
|
+
*/
|
|
117
|
+
private checkBudget;
|
|
118
|
+
/** Persist the ranked leaderboard JSON snapshot onto the session (§9.2). */
|
|
119
|
+
private snapshotLeaderboard;
|
|
120
|
+
/**
|
|
121
|
+
* Finalize the session: `Completed` when the plan ran out cleanly, or `Paused`
|
|
122
|
+
* when a budget bound stopped it (clean pause, never overrun). Surfaces the
|
|
123
|
+
* best model.
|
|
124
|
+
*/
|
|
125
|
+
private finalizeSession;
|
|
126
|
+
/** Remove the dispatched wave's experiments from the remaining pool (by identity). */
|
|
127
|
+
private removeFromRemaining;
|
|
128
|
+
/** Derive a session/experiment name from the plan goal (first 80 chars). */
|
|
129
|
+
private deriveName;
|
|
130
|
+
/**
|
|
131
|
+
* Save a BaseEntity and throw with `LatestResult.CompleteMessage` on failure
|
|
132
|
+
* (Save returns boolean, never throws on logical failure — CLAUDE.md).
|
|
133
|
+
*/
|
|
134
|
+
private saveOrThrow;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=experiment-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experiment-orchestrator.d.ts","sourceRoot":"","sources":["../../src/experiment/experiment-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,wCAAwC,CAAC;AAQhD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAM7B,MAAM,SAAS,CAAC;AAoBjB;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC;;;;;;;OAOG;IACU,UAAU,CACrB,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAwEnC,mEAAmE;IACnE,OAAO,CAAC,cAAc;IAMtB;;;;OAIG;YACW,iBAAiB;IAmB/B,oFAAoF;IACpF,OAAO,CAAC,aAAa;IAWrB;;;;OAIG;YACW,aAAa;IAuB3B,oFAAoF;YACtE,QAAQ;IAKtB;;;;;OAKG;YACW,OAAO;IA4DrB,kFAAkF;YACpE,eAAe;IAmB7B;;;;OAIG;YACW,cAAc;IAiC5B,iFAAiF;YACnE,aAAa;IAiB3B;;;;;OAKG;YACW,YAAY;IAqC1B;;;;OAIG;YACW,UAAU;IAmBxB,qFAAqF;IACrF,OAAO,CAAC,cAAc;IAItB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAkBnB,4EAA4E;YAC9D,mBAAmB;IAYjC;;;;OAIG;YACW,eAAe;IAkB7B,sFAAsF;IACtF,OAAO,CAAC,mBAAmB;IAS3B,4EAA4E;IAC5E,OAAO,CAAC,UAAU;IAMlB;;;OAGG;YACW,WAAW;CAU1B"}
|