@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,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/model-scoring-action-generator
|
|
3
|
+
*
|
|
4
|
+
* **Per-model scoring Action generator** (plan PS2-2). When a Predictive Studio
|
|
5
|
+
* model is promoted to a usable status (`Published`), this service generates an
|
|
6
|
+
* idempotent child Action — `Score with <Model> v<n>` — so every published model
|
|
7
|
+
* becomes a first-class, discoverable Action (ActionSmith / CodeSmith pick it up
|
|
8
|
+
* for free) without any per-model code or AI codegen.
|
|
9
|
+
*
|
|
10
|
+
* ## Composition, not inheritance (CLAUDE.md: Actions)
|
|
11
|
+
* The generated row is a *child* of the canonical **Score Record Set** parent: it
|
|
12
|
+
* carries the parent's `ParentID` (metadata link only) and reuses the SAME
|
|
13
|
+
* `DriverClass` (`PredictiveStudioScoreRecordSetAction`). That class already reads
|
|
14
|
+
* the `ModelID` / `Scope` / `WriteBack` params, so the child needs no new
|
|
15
|
+
* implementation. The only thing that makes it model-specific is its `ModelID`
|
|
16
|
+
* input param's `DefaultValue`, which is pre-set to the model's id — ActionEngine
|
|
17
|
+
* seeds each param from its `DefaultValue` before invoke, so omitting `ModelID`
|
|
18
|
+
* scores with this model.
|
|
19
|
+
*
|
|
20
|
+
* ## Idempotency
|
|
21
|
+
* Mirrors {@link IntegrationActionGenerator}: the Action is found-or-created by its
|
|
22
|
+
* deterministic Name, and its child params are deleted + recreated on every run so
|
|
23
|
+
* they stay exactly in sync with the parent's contract.
|
|
24
|
+
*
|
|
25
|
+
* All saves are checked and failures are logged (never thrown up to the promote —
|
|
26
|
+
* action generation is an enhancement, not part of the promotion contract).
|
|
27
|
+
*/
|
|
28
|
+
import { RunView, LogError, LogStatus } from '@memberjunction/core';
|
|
29
|
+
import { SCORE_RECORD_SET_DRIVER_CLASS } from './score-record-set.action.js';
|
|
30
|
+
/** Name of the find-or-create Action Category that holds per-model scoring actions. */
|
|
31
|
+
const MODELS_CATEGORY_NAME = 'Predictive Studio Models';
|
|
32
|
+
/** The canonical parent Action's Name (the metadata "Score Record Set" row). */
|
|
33
|
+
const PARENT_ACTION_NAME = 'Score Record Set';
|
|
34
|
+
/** Font Awesome icon for generated scoring actions (matches the parent). */
|
|
35
|
+
const SCORING_ICON_CLASS = 'fa-solid fa-gauge-high';
|
|
36
|
+
/**
|
|
37
|
+
* Generates (and disables) the per-model "Score with <Model> v<n>" child Action.
|
|
38
|
+
* Stateless + idempotent — safe to call on every promotion.
|
|
39
|
+
*/
|
|
40
|
+
export class ModelScoringActionGenerator {
|
|
41
|
+
/**
|
|
42
|
+
* Find-or-create the per-model scoring Action for `model` and reconcile its
|
|
43
|
+
* params. Idempotent on the deterministic Action Name. Logs and returns on any
|
|
44
|
+
* failure (the parent action is missing, a save fails) rather than throwing —
|
|
45
|
+
* callers must never let scoring-action generation break the promotion path.
|
|
46
|
+
*/
|
|
47
|
+
async generateForModel(model, contextUser, provider) {
|
|
48
|
+
const parent = await this.findScoreRecordSetParentAction(provider, contextUser);
|
|
49
|
+
if (!parent) {
|
|
50
|
+
LogError(`ModelScoringActionGenerator: parent action '${PARENT_ACTION_NAME}' (DriverClass ` +
|
|
51
|
+
`'${SCORE_RECORD_SET_DRIVER_CLASS}') not found — cannot generate a scoring action for model ` +
|
|
52
|
+
`'${model.ID}'. Skipping.`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const categoryID = await this.ensureModelsActionCategory(provider, contextUser);
|
|
56
|
+
const action = await this.upsertScoringAction(model, parent, categoryID, provider, contextUser);
|
|
57
|
+
if (!action) {
|
|
58
|
+
return; // upsert already logged the failure
|
|
59
|
+
}
|
|
60
|
+
await this.recreateParams(action.ID, model, provider, contextUser);
|
|
61
|
+
LogStatus(`ModelScoringActionGenerator: ensured scoring action '${action.Name}' for model '${model.ID}'.`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Disable the generated scoring Action for `model` (e.g. when the model is
|
|
65
|
+
* Archived) by flipping its Status to `Disabled`. A no-op when no generated
|
|
66
|
+
* action exists. Never throws.
|
|
67
|
+
*/
|
|
68
|
+
async disableForModel(model, contextUser, provider) {
|
|
69
|
+
const name = this.scoringActionName(model);
|
|
70
|
+
const existing = await this.findActionByName(name, provider, contextUser);
|
|
71
|
+
if (!existing) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (existing.Status === 'Disabled') {
|
|
75
|
+
return; // already disabled — nothing to do
|
|
76
|
+
}
|
|
77
|
+
existing.Status = 'Disabled';
|
|
78
|
+
if (!(await existing.Save())) {
|
|
79
|
+
LogError(`ModelScoringActionGenerator: failed to disable action '${name}': ` +
|
|
80
|
+
`${existing.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
LogStatus(`ModelScoringActionGenerator: disabled scoring action '${name}' for archived model '${model.ID}'.`);
|
|
84
|
+
}
|
|
85
|
+
// ----- category ------------------------------------------------------------
|
|
86
|
+
/**
|
|
87
|
+
* Find-or-create the `MJ: Action Categories` row that groups all per-model
|
|
88
|
+
* scoring actions. Idempotent (find by Name first). Returns its ID, or null if
|
|
89
|
+
* the category couldn't be created (logged).
|
|
90
|
+
*/
|
|
91
|
+
async ensureModelsActionCategory(provider, contextUser) {
|
|
92
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
93
|
+
const existing = await rv.RunView({
|
|
94
|
+
EntityName: 'MJ: Action Categories',
|
|
95
|
+
ExtraFilter: `Name='${this.escape(MODELS_CATEGORY_NAME)}'`,
|
|
96
|
+
MaxRows: 1,
|
|
97
|
+
ResultType: 'entity_object',
|
|
98
|
+
}, contextUser);
|
|
99
|
+
if (existing.Success && existing.Results.length > 0) {
|
|
100
|
+
return existing.Results[0].ID;
|
|
101
|
+
}
|
|
102
|
+
const cat = await provider.GetEntityObject('MJ: Action Categories', contextUser);
|
|
103
|
+
cat.NewRecord();
|
|
104
|
+
cat.Name = MODELS_CATEGORY_NAME;
|
|
105
|
+
cat.Description =
|
|
106
|
+
'Per-model scoring actions auto-generated when a Predictive Studio model is published.';
|
|
107
|
+
cat.Status = 'Active';
|
|
108
|
+
if (!(await cat.Save())) {
|
|
109
|
+
LogError(`ModelScoringActionGenerator: failed to create category '${MODELS_CATEGORY_NAME}': ` +
|
|
110
|
+
`${cat.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return cat.ID;
|
|
114
|
+
}
|
|
115
|
+
// ----- parent lookup -------------------------------------------------------
|
|
116
|
+
/**
|
|
117
|
+
* Load the canonical parent **Score Record Set** Action — the top-level row
|
|
118
|
+
* (ParentID null) whose DriverClass is the scoring driver. Returns null (caller
|
|
119
|
+
* logs + bails) when it's missing.
|
|
120
|
+
*/
|
|
121
|
+
async findScoreRecordSetParentAction(provider, contextUser) {
|
|
122
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
123
|
+
const result = await rv.RunView({
|
|
124
|
+
EntityName: 'MJ: Actions',
|
|
125
|
+
ExtraFilter: `Name='${this.escape(PARENT_ACTION_NAME)}' AND ` +
|
|
126
|
+
`DriverClass='${this.escape(SCORE_RECORD_SET_DRIVER_CLASS)}' AND ParentID IS NULL`,
|
|
127
|
+
MaxRows: 1,
|
|
128
|
+
ResultType: 'entity_object',
|
|
129
|
+
}, contextUser);
|
|
130
|
+
return result.Success && result.Results.length > 0 ? result.Results[0] : null;
|
|
131
|
+
}
|
|
132
|
+
// ----- action upsert (idempotent) -----------------------------------------
|
|
133
|
+
/**
|
|
134
|
+
* Find-or-create the per-model scoring Action by its deterministic Name and
|
|
135
|
+
* apply its fields. The child reuses the parent's DriverClass (composition) and
|
|
136
|
+
* links via ParentID. Returns the saved row, or null on save failure (logged).
|
|
137
|
+
*/
|
|
138
|
+
async upsertScoringAction(model, parent, categoryID, provider, contextUser) {
|
|
139
|
+
const name = this.scoringActionName(model);
|
|
140
|
+
const existing = await this.findActionByName(name, provider, contextUser);
|
|
141
|
+
const action = existing ?? (await provider.GetEntityObject('MJ: Actions', contextUser));
|
|
142
|
+
if (!existing) {
|
|
143
|
+
action.NewRecord();
|
|
144
|
+
}
|
|
145
|
+
action.Name = name;
|
|
146
|
+
action.Description = this.scoringActionDescription(model);
|
|
147
|
+
action.Type = 'Custom';
|
|
148
|
+
action.DriverClass = SCORE_RECORD_SET_DRIVER_CLASS;
|
|
149
|
+
action.ParentID = parent.ID;
|
|
150
|
+
if (categoryID) {
|
|
151
|
+
action.CategoryID = categoryID;
|
|
152
|
+
}
|
|
153
|
+
action.Status = 'Active';
|
|
154
|
+
action.IconClass = SCORING_ICON_CLASS;
|
|
155
|
+
if (!(await action.Save())) {
|
|
156
|
+
LogError(`ModelScoringActionGenerator: failed to save scoring action '${name}': ` +
|
|
157
|
+
`${action.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return action;
|
|
161
|
+
}
|
|
162
|
+
/** Load an Action by exact Name (idempotency lookup), or null. */
|
|
163
|
+
async findActionByName(name, provider, contextUser) {
|
|
164
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
165
|
+
const result = await rv.RunView({
|
|
166
|
+
EntityName: 'MJ: Actions',
|
|
167
|
+
ExtraFilter: `Name='${this.escape(name)}'`,
|
|
168
|
+
MaxRows: 1,
|
|
169
|
+
ResultType: 'entity_object',
|
|
170
|
+
}, contextUser);
|
|
171
|
+
return result.Success && result.Results.length > 0 ? result.Results[0] : null;
|
|
172
|
+
}
|
|
173
|
+
// ----- param recreation ----------------------------------------------------
|
|
174
|
+
/**
|
|
175
|
+
* Delete the action's existing params and recreate the canonical scoring
|
|
176
|
+
* param set (matching the parent's contract). The `ModelID` input is pre-set to
|
|
177
|
+
* this model's id via `DefaultValue` so omitting it scores with this model.
|
|
178
|
+
*/
|
|
179
|
+
async recreateParams(actionID, model, provider, contextUser) {
|
|
180
|
+
await this.deleteExistingParams(actionID, provider, contextUser);
|
|
181
|
+
for (const spec of this.buildParamSpecs(model)) {
|
|
182
|
+
const param = await provider.GetEntityObject('MJ: Action Params', contextUser);
|
|
183
|
+
param.NewRecord();
|
|
184
|
+
param.ActionID = actionID;
|
|
185
|
+
param.Name = spec.Name;
|
|
186
|
+
param.Type = spec.Type;
|
|
187
|
+
param.ValueType = spec.ValueType;
|
|
188
|
+
param.IsArray = false;
|
|
189
|
+
param.IsRequired = spec.IsRequired;
|
|
190
|
+
param.Description = spec.Description;
|
|
191
|
+
if (spec.DefaultValue != null) {
|
|
192
|
+
param.DefaultValue = spec.DefaultValue;
|
|
193
|
+
}
|
|
194
|
+
if (!(await param.Save())) {
|
|
195
|
+
LogError(`ModelScoringActionGenerator: failed to save param '${spec.Name}' for action ${actionID}: ` +
|
|
196
|
+
`${param.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Load + delete all `MJ: Action Params` rows for the given action. */
|
|
201
|
+
async deleteExistingParams(actionID, provider, contextUser) {
|
|
202
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
203
|
+
const result = await rv.RunView({
|
|
204
|
+
EntityName: 'MJ: Action Params',
|
|
205
|
+
ExtraFilter: `ActionID='${this.escape(actionID)}'`,
|
|
206
|
+
ResultType: 'entity_object',
|
|
207
|
+
}, contextUser);
|
|
208
|
+
if (!result.Success) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
for (const row of result.Results) {
|
|
212
|
+
if (!(await row.Delete())) {
|
|
213
|
+
LogError(`ModelScoringActionGenerator: failed to delete param ${row.ID} for action ${actionID}: ` +
|
|
214
|
+
`${row.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The canonical scoring param set, mirroring the parent **Score Record Set**
|
|
220
|
+
* action: `ModelID` (pre-seeded for this model), `Scope`, `WriteBack`, plus the
|
|
221
|
+
* five output params. Kept DRY via a small spec list.
|
|
222
|
+
*/
|
|
223
|
+
buildParamSpecs(model) {
|
|
224
|
+
return [
|
|
225
|
+
{
|
|
226
|
+
Name: 'ModelID',
|
|
227
|
+
Type: 'Input',
|
|
228
|
+
ValueType: 'Scalar',
|
|
229
|
+
IsRequired: false,
|
|
230
|
+
DefaultValue: model.ID,
|
|
231
|
+
Description: 'Pre-set to the model this action scores with; override only for advanced reuse.',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
Name: 'Scope',
|
|
235
|
+
Type: 'Input',
|
|
236
|
+
ValueType: 'Simple Object',
|
|
237
|
+
IsRequired: true,
|
|
238
|
+
Description: 'JSON describing the records to score. Populate exactly one of: records (id/pk array), ' +
|
|
239
|
+
'viewId, listId, filter ({entityName, extraFilter, maxRows}), single ({entityName, primaryKey}).',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
Name: 'WriteBack',
|
|
243
|
+
Type: 'Input',
|
|
244
|
+
ValueType: 'Simple Object',
|
|
245
|
+
IsRequired: false,
|
|
246
|
+
Description: 'Optional. true to write scores back with the model\'s default mapping, or an object ' +
|
|
247
|
+
'{ OutputMapping: ... } to write to a specific column/child record. When omitted, predictions ' +
|
|
248
|
+
'are returned ephemerally.',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
Name: 'ScoredCount',
|
|
252
|
+
Type: 'Output',
|
|
253
|
+
ValueType: 'Scalar',
|
|
254
|
+
IsRequired: false,
|
|
255
|
+
Description: 'Number of records successfully scored.',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
Name: 'FailedCount',
|
|
259
|
+
Type: 'Output',
|
|
260
|
+
ValueType: 'Scalar',
|
|
261
|
+
IsRequired: false,
|
|
262
|
+
Description: 'Number of records that failed to score.',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
Name: 'SkippedCount',
|
|
266
|
+
Type: 'Output',
|
|
267
|
+
ValueType: 'Scalar',
|
|
268
|
+
IsRequired: false,
|
|
269
|
+
Description: 'Number of records the processor skipped (e.g. ineligible / filtered out).',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
Name: 'WroteBack',
|
|
273
|
+
Type: 'Output',
|
|
274
|
+
ValueType: 'Scalar',
|
|
275
|
+
IsRequired: false,
|
|
276
|
+
Description: 'True when scores were written back to the target (predictions are then NOT returned ephemerally).',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
Name: 'Predictions',
|
|
280
|
+
Type: 'Output',
|
|
281
|
+
ValueType: 'Scalar',
|
|
282
|
+
IsRequired: false,
|
|
283
|
+
Description: 'JSON array of ephemeral predictions ({recordId, score, class}), present only when WriteBack was not requested.',
|
|
284
|
+
},
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
// ----- naming + helpers ----------------------------------------------------
|
|
288
|
+
/**
|
|
289
|
+
* Deterministic Action Name: `Score with <label> v<version>`. The model has no
|
|
290
|
+
* `Name` column; its human label is the producing pipeline's name (the
|
|
291
|
+
* denormalized `Pipeline` view field), falling back to the model id.
|
|
292
|
+
*/
|
|
293
|
+
scoringActionName(model) {
|
|
294
|
+
return `Score with ${this.modelLabel(model)} v${this.modelVersion(model)}`;
|
|
295
|
+
}
|
|
296
|
+
/** Human-readable description naming the model label + version. */
|
|
297
|
+
scoringActionDescription(model) {
|
|
298
|
+
return (`Scores a set of records with the published model "${this.modelLabel(model)}" (v${this.modelVersion(model)}). ` +
|
|
299
|
+
`Auto-generated on publish; reuses the Score Record Set driver with ModelID pre-set to this model. ` +
|
|
300
|
+
`Supply a Scope (records / view / list / filter / single) and optionally WriteBack.`);
|
|
301
|
+
}
|
|
302
|
+
/** The model's human label — its pipeline name, or the model id when unset. */
|
|
303
|
+
modelLabel(model) {
|
|
304
|
+
const pipeline = model.Pipeline?.trim();
|
|
305
|
+
return pipeline && pipeline.length > 0 ? pipeline : model.ID;
|
|
306
|
+
}
|
|
307
|
+
/** The model's version, defaulting to 1 when unset. */
|
|
308
|
+
modelVersion(model) {
|
|
309
|
+
return model.Version ?? 1;
|
|
310
|
+
}
|
|
311
|
+
/** Single-quote-escape a value for safe SQL filter interpolation. */
|
|
312
|
+
escape(value) {
|
|
313
|
+
return value.replace(/'/g, "''");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=model-scoring-action-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-scoring-action-generator.js","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sB;QAChD,OAAO,cAAc,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7E,CAAC;IAED,mEAAmE;IACzD,wBAAwB,CAAC,KAAsB;QACvD,OAAO,CACL,qDAAqD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK;YAC/G,oGAAoG;YACpG,oFAAoF,CACrF,CAAC;IACJ,CAAC;IAED,+EAA+E;IACrE,UAAU,CAAC,KAAsB;QACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;QACxC,OAAO,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/D,CAAC;IAED,uDAAuD;IAC7C,YAAY,CAAC,KAAsB;QAC3C,OAAO,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,qEAAqE;IAC7D,MAAM,CAAC,KAAa;QAC1B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/promote-model.action
|
|
3
|
+
*
|
|
4
|
+
* **Promote ML Model** action — the thin Action boundary over the model lifecycle
|
|
5
|
+
* transition (plan §6.4 / §12). It lets an agent / workflow / UI move a model
|
|
6
|
+
* through `Draft → Validated → Published → Archived`, **enforcing the leakage
|
|
7
|
+
* sign-off gate**: a leakage-flagged model cannot be promoted without an explicit
|
|
8
|
+
* human/agent `SignOff`.
|
|
9
|
+
*
|
|
10
|
+
* Per CLAUDE.md "Actions are boundaries": this action does NOT mutate the model's
|
|
11
|
+
* metrics, artifact, or any training payload — promotion is a **lifecycle-only**
|
|
12
|
+
* transition (the model is immutable, §6.4). It validates `ModelID` +
|
|
13
|
+
* `TargetStatus`, delegates the leakage check + transition to an injectable
|
|
14
|
+
* {@link IModelPromotionGate}, and maps the new status back.
|
|
15
|
+
*
|
|
16
|
+
* The gate is an injectable seam so unit tests substitute a mock with no live DB.
|
|
17
|
+
*/
|
|
18
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
19
|
+
import { type UserInfo, type IMetadataProvider } from '@memberjunction/core';
|
|
20
|
+
import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
|
|
21
|
+
/** The driver-class key this action registers under (matches the metadata row). */
|
|
22
|
+
export declare const PROMOTE_MODEL_DRIVER_CLASS = "PredictiveStudioPromoteModelAction";
|
|
23
|
+
/** The lifecycle statuses a model may be promoted/transitioned to. */
|
|
24
|
+
export type PromotableStatus = 'Validated' | 'Published' | 'Archived';
|
|
25
|
+
/** The set of valid target statuses (used for validation). */
|
|
26
|
+
export declare const PROMOTABLE_STATUSES: readonly PromotableStatus[];
|
|
27
|
+
/** The model id + requested transition + sign-off, handed to the gate. */
|
|
28
|
+
export interface PromoteModelRequest {
|
|
29
|
+
modelId: string;
|
|
30
|
+
targetStatus: PromotableStatus;
|
|
31
|
+
signOff: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Justification for a sign-off override. REQUIRED (non-empty) when `signOff`
|
|
34
|
+
* overrides a leakage-FLAGGED model — the gate refuses the override without a
|
|
35
|
+
* reason, then persists a sign-off audit note. Ignored when the model isn't
|
|
36
|
+
* flagged (sign-off has nothing to override).
|
|
37
|
+
*/
|
|
38
|
+
reason?: string;
|
|
39
|
+
contextUser?: UserInfo;
|
|
40
|
+
provider?: IMetadataProvider;
|
|
41
|
+
}
|
|
42
|
+
/** Outcome of a promotion attempt. */
|
|
43
|
+
export type PromoteModelOutcome = {
|
|
44
|
+
kind: 'promoted';
|
|
45
|
+
newStatus: PromotableStatus;
|
|
46
|
+
signOffNote?: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'refused-leakage';
|
|
49
|
+
topFeature?: string;
|
|
50
|
+
topShare?: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'signoff-reason-required';
|
|
53
|
+
topFeature?: string;
|
|
54
|
+
topShare?: number;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'invalid-transition';
|
|
57
|
+
currentStatus: string;
|
|
58
|
+
targetStatus: PromotableStatus;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'not-found';
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'save-failed';
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The single lifecycle-transition seam this action depends on — load the model,
|
|
67
|
+
* enforce the leakage sign-off gate, and transition the status (lifecycle only).
|
|
68
|
+
* The production implementation ({@link ProductionModelPromotionGate}) loads the
|
|
69
|
+
* `MJ: ML Models` row, determines leakage from its frozen feature importance, and
|
|
70
|
+
* saves only the `Status`; tests inject a deterministic fake.
|
|
71
|
+
*/
|
|
72
|
+
export interface IModelPromotionGate {
|
|
73
|
+
/** Attempt the promotion, enforcing the leakage sign-off gate. */
|
|
74
|
+
promote(request: PromoteModelRequest): Promise<PromoteModelOutcome>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Transitions a model's lifecycle status with the leakage sign-off gate enforced.
|
|
78
|
+
* Output: `Status` (the new status string, on success).
|
|
79
|
+
*/
|
|
80
|
+
export declare class PredictiveStudioPromoteModelAction extends BasePredictiveStudioAction {
|
|
81
|
+
/** @inheritdoc */
|
|
82
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
83
|
+
/** Map the gate outcome to an {@link ActionResultSimple}. */
|
|
84
|
+
protected mapOutcome(params: RunActionParams, modelId: string, outcome: PromoteModelOutcome): ActionResultSimple;
|
|
85
|
+
/** Compose the plain-language refusal message for a leakage-flagged model. */
|
|
86
|
+
protected leakageRefusalMessage(modelId: string, outcome: Extract<PromoteModelOutcome, {
|
|
87
|
+
kind: 'refused-leakage';
|
|
88
|
+
}>): string;
|
|
89
|
+
/**
|
|
90
|
+
* Compose the message when a sign-off override of a leakage-flagged model was
|
|
91
|
+
* requested WITHOUT a justification reason — the override is refused until one is
|
|
92
|
+
* supplied so the audit trail is never empty.
|
|
93
|
+
*/
|
|
94
|
+
protected signOffReasonRequiredMessage(modelId: string, outcome: Extract<PromoteModelOutcome, {
|
|
95
|
+
kind: 'signoff-reason-required';
|
|
96
|
+
}>): string;
|
|
97
|
+
/** Parse + validate the `TargetStatus` param against the promotable set. */
|
|
98
|
+
protected parseTargetStatus(params: RunActionParams): PromotableStatus | undefined;
|
|
99
|
+
/** Construct the production promotion gate. Overridable so tests inject a mock. */
|
|
100
|
+
protected createGate(): IModelPromotionGate;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=promote-model.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote-model.action.d.ts","sourceRoot":"","sources":["../../src/actions/promote-model.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,EAAY,KAAK,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAG7E,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,uCAAuC,CAAC;AAE/E,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtE,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,EAAE,SAAS,gBAAgB,EAA2C,CAAC;AAEvG,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,OAAO,EAAE,O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MAAM,EACf,OAAO,EAAE,OAAO,CAAC,mBAAmB,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,GACjE,MAAM;IAWT;;;;OAIG;IACH,SAAS,CAAC,4BAA4B,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,CAAC,mBAAmB,EAAE;QAAE,IAAI,EAAE,yBAAyB,CAAA;KAAE,CAAC,GACzE,MAAM;IAcT,4EAA4E;IAC5E,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS;IAWlF,mFAAmF;IACnF,SAAS,CAAC,UAAU,IAAI,mBAAmB;CAG5C"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/promote-model.action
|
|
3
|
+
*
|
|
4
|
+
* **Promote ML Model** action — the thin Action boundary over the model lifecycle
|
|
5
|
+
* transition (plan §6.4 / §12). It lets an agent / workflow / UI move a model
|
|
6
|
+
* through `Draft → Validated → Published → Archived`, **enforcing the leakage
|
|
7
|
+
* sign-off gate**: a leakage-flagged model cannot be promoted without an explicit
|
|
8
|
+
* human/agent `SignOff`.
|
|
9
|
+
*
|
|
10
|
+
* Per CLAUDE.md "Actions are boundaries": this action does NOT mutate the model's
|
|
11
|
+
* metrics, artifact, or any training payload — promotion is a **lifecycle-only**
|
|
12
|
+
* transition (the model is immutable, §6.4). It validates `ModelID` +
|
|
13
|
+
* `TargetStatus`, delegates the leakage check + transition to an injectable
|
|
14
|
+
* {@link IModelPromotionGate}, and maps the new status back.
|
|
15
|
+
*
|
|
16
|
+
* The gate is an injectable seam so unit tests substitute a mock with no live DB.
|
|
17
|
+
*/
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
25
|
+
import { LogError } from '@memberjunction/core';
|
|
26
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
27
|
+
import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
|
|
28
|
+
import { ProductionModelPromotionGate } from './promote-model.gate.js';
|
|
29
|
+
/** The driver-class key this action registers under (matches the metadata row). */
|
|
30
|
+
export const PROMOTE_MODEL_DRIVER_CLASS = 'PredictiveStudioPromoteModelAction';
|
|
31
|
+
/** The set of valid target statuses (used for validation). */
|
|
32
|
+
export const PROMOTABLE_STATUSES = ['Validated', 'Published', 'Archived'];
|
|
33
|
+
/**
|
|
34
|
+
* Transitions a model's lifecycle status with the leakage sign-off gate enforced.
|
|
35
|
+
* Output: `Status` (the new status string, on success).
|
|
36
|
+
*/
|
|
37
|
+
let PredictiveStudioPromoteModelAction = class PredictiveStudioPromoteModelAction extends BasePredictiveStudioAction {
|
|
38
|
+
/** @inheritdoc */
|
|
39
|
+
async InternalRunAction(params) {
|
|
40
|
+
try {
|
|
41
|
+
const modelId = this.getStringParam(params, 'ModelID');
|
|
42
|
+
if (!modelId) {
|
|
43
|
+
return this.fail('VALIDATION_ERROR', 'ModelID parameter is required');
|
|
44
|
+
}
|
|
45
|
+
const targetStatus = this.parseTargetStatus(params);
|
|
46
|
+
if (!targetStatus) {
|
|
47
|
+
return this.fail('VALIDATION_ERROR', `TargetStatus parameter is required and must be one of: ${PROMOTABLE_STATUSES.join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
const signOff = this.getBooleanParam(params, 'SignOff', false);
|
|
50
|
+
const reason = this.getStringParam(params, 'Reason');
|
|
51
|
+
const gate = this.createGate();
|
|
52
|
+
const outcome = await gate.promote({
|
|
53
|
+
modelId,
|
|
54
|
+
targetStatus,
|
|
55
|
+
signOff,
|
|
56
|
+
reason,
|
|
57
|
+
contextUser: params.ContextUser,
|
|
58
|
+
provider: params.Provider,
|
|
59
|
+
});
|
|
60
|
+
return this.mapOutcome(params, modelId, outcome);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
LogError(e);
|
|
64
|
+
return this.fail('PROMOTION_FAILED', `Promotion failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Map the gate outcome to an {@link ActionResultSimple}. */
|
|
68
|
+
mapOutcome(params, modelId, outcome) {
|
|
69
|
+
switch (outcome.kind) {
|
|
70
|
+
case 'promoted':
|
|
71
|
+
this.addOutputParam(params, 'Status', outcome.newStatus);
|
|
72
|
+
if (outcome.signOffNote) {
|
|
73
|
+
this.addOutputParam(params, 'SignOffNote', outcome.signOffNote);
|
|
74
|
+
}
|
|
75
|
+
return this.ok(params, outcome.signOffNote
|
|
76
|
+
? `Model ${modelId} transitioned to ${outcome.newStatus}. ${outcome.signOffNote}`
|
|
77
|
+
: `Model ${modelId} transitioned to ${outcome.newStatus}.`);
|
|
78
|
+
case 'refused-leakage':
|
|
79
|
+
return this.fail('LEAKAGE_SIGNOFF_REQUIRED', this.leakageRefusalMessage(modelId, outcome));
|
|
80
|
+
case 'signoff-reason-required':
|
|
81
|
+
return this.fail('SIGNOFF_REASON_REQUIRED', this.signOffReasonRequiredMessage(modelId, outcome));
|
|
82
|
+
case 'invalid-transition':
|
|
83
|
+
return this.fail('INVALID_TRANSITION', `Model ${modelId} cannot move from '${outcome.currentStatus}' to '${outcome.targetStatus}'. ` +
|
|
84
|
+
'Allowed lifecycle: Draft → Validated → Published → Archived (with Published ↔ Archived).');
|
|
85
|
+
case 'not-found':
|
|
86
|
+
return this.fail('MODEL_NOT_FOUND', `ML Model '${modelId}' was not found.`);
|
|
87
|
+
case 'save-failed':
|
|
88
|
+
return this.fail('SAVE_FAILED', `Failed to transition model '${modelId}': ${outcome.message}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Compose the plain-language refusal message for a leakage-flagged model. */
|
|
92
|
+
leakageRefusalMessage(modelId, outcome) {
|
|
93
|
+
const detail = outcome.topFeature != null
|
|
94
|
+
? ` One feature ("${outcome.topFeature}") accounts for ${(((outcome.topShare ?? 0) * 100)).toFixed(0)}% of the model's predictions, which often signals the model is accidentally peeking at the answer.`
|
|
95
|
+
: '';
|
|
96
|
+
return (`Model ${modelId} was flagged for possible target leakage and cannot be promoted without sign-off.${detail} ` +
|
|
97
|
+
'A human must review the model and re-run this action with SignOff=true to confirm the result is legitimate.');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compose the message when a sign-off override of a leakage-flagged model was
|
|
101
|
+
* requested WITHOUT a justification reason — the override is refused until one is
|
|
102
|
+
* supplied so the audit trail is never empty.
|
|
103
|
+
*/
|
|
104
|
+
signOffReasonRequiredMessage(modelId, outcome) {
|
|
105
|
+
const detail = outcome.topFeature != null
|
|
106
|
+
? ` (one feature, "${outcome.topFeature}", dominates this model's predictions)`
|
|
107
|
+
: '';
|
|
108
|
+
return (`Model ${modelId} is leakage-flagged${detail} and SignOff=true was supplied without a Reason. ` +
|
|
109
|
+
'Overriding a leakage flag requires a non-empty Reason so the sign-off is auditable. ' +
|
|
110
|
+
'Re-run this action with both SignOff=true and a Reason explaining why the result is legitimate.');
|
|
111
|
+
}
|
|
112
|
+
// ----- param parsing -------------------------------------------------------
|
|
113
|
+
/** Parse + validate the `TargetStatus` param against the promotable set. */
|
|
114
|
+
parseTargetStatus(params) {
|
|
115
|
+
const raw = this.getStringParam(params, 'TargetStatus');
|
|
116
|
+
if (!raw) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const match = PROMOTABLE_STATUSES.find((s) => s.toLowerCase() === raw.toLowerCase());
|
|
120
|
+
return match;
|
|
121
|
+
}
|
|
122
|
+
// ----- injectable gate seam (overridden in tests) --------------------------
|
|
123
|
+
/** Construct the production promotion gate. Overridable so tests inject a mock. */
|
|
124
|
+
createGate() {
|
|
125
|
+
return new ProductionModelPromotionGate();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
PredictiveStudioPromoteModelAction = __decorate([
|
|
129
|
+
RegisterClass(BaseAction, PROMOTE_MODEL_DRIVER_CLASS)
|
|
130
|
+
], PredictiveStudioPromoteModelAction);
|
|
131
|
+
export { PredictiveStudioPromoteModelAction };
|
|
132
|
+
//# sourceMappingURL=promote-model.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote-model.action.js","sourceRoot":"","sources":["../../src/actions/promote-model.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAyC,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEpE,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AAK/E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAgC,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAuCvG;;;GAGG;AAEI,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,0BAA0B;IAChF,kBAAkB;IACR,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACvD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO,EA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