@zhuoyuezs/ml-platform 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/checksums.json +155 -0
  2. package/package.json +3 -2
  3. package/release.json +52 -0
  4. package/runtime/business-client/README.md +110 -0
  5. package/runtime/business-client/package-lock.json +19 -0
  6. package/runtime/business-client/package.json +23 -0
  7. package/runtime/business-client/src/catalog.js +214 -0
  8. package/runtime/business-client/src/cli.js +538 -0
  9. package/runtime/business-client/src/config.js +56 -0
  10. package/runtime/business-client/src/http.js +254 -0
  11. package/scripts/verify-release-package.js +28 -0
  12. package/skills/feature-management/SKILL.md +491 -0
  13. package/skills/feature-management/agents/openai.yaml +4 -0
  14. package/skills/feature-management/assets/catalog-template/catalog.json +23 -0
  15. package/skills/feature-management/assets/catalog-template/datasets/example_temperature_training.v1.json +40 -0
  16. package/skills/feature-management/assets/catalog-template/feature_sets/example_temperature_core.v1.json +14 -0
  17. package/skills/feature-management/assets/catalog-template/features/example_temperature_mean_5m.v1.json +28 -0
  18. package/skills/feature-management/assets/catalog-template/operator_package/pyproject.toml +12 -0
  19. package/skills/feature-management/assets/catalog-template/operator_package/src/business_feature_operator_template/__init__.py +39 -0
  20. package/skills/feature-management/assets/catalog-template/operator_package/tests/test_operator.py +83 -0
  21. package/skills/feature-management/assets/catalog-template/operators/example_temperature_features.v1.json +58 -0
  22. package/skills/feature-management/assets/catalog-template/parameters/example_temperature.v1.json +58 -0
  23. package/skills/feature-management/references/commands.md +358 -0
  24. package/skills/feature-management/references/contracts.md +766 -0
  25. package/skills/feature-management/references/operator-authoring.md +175 -0
  26. package/skills/feature-management/references/platform-capability-guide.md +75 -0
  27. package/skills/feature-management/references/supervised-datasets.md +101 -0
  28. package/skills/model-lifecycle-management/SKILL.md +38 -0
  29. package/skills/model-lifecycle-management/agents/openai.yaml +4 -0
  30. package/skills/model-lifecycle-management/references/discovery.md +89 -0
  31. package/skills/model-lifecycle-management/references/evaluation.md +172 -0
  32. package/skills/model-lifecycle-management/references/packaging.md +58 -0
  33. package/skills/model-lifecycle-management/references/training-contracts.md +259 -0
  34. package/skills/model-lifecycle-management/references/training.md +107 -0
@@ -0,0 +1,58 @@
1
+ # Model Packaging Commands
2
+
3
+ ## Request shape and managed runtime
4
+
5
+ ```json
6
+ {
7
+ "model_artifact_id": "replace_registered_model_artifact_id",
8
+ "package_version": "1.0.0",
9
+ "input_modes": ["inline"]
10
+ }
11
+ ```
12
+
13
+ The artifact must be `REGISTERED` and pass validation. Creation submits work;
14
+ first use `validate-model-package` for read-only contract/runtime preflight. Version defaults to `1` if omitted;
15
+ use an explicit immutable version (semantic versioning is a convention, not an
16
+ enforced three-component schema). Capture `package.package_id` and
17
+ `package.package_version` from the creation response.
18
+
19
+ The server resolves images and destination from the approved trainer/device
20
+ runtime configuration. Optional request keys `base_image`, `worker_image`,
21
+ `builder_image`, `destination_repository` are equality assertions against that
22
+ configuration, not arbitrary overrides. Omit them when using managed defaults;
23
+ do not guess registries or pass deployment secrets. A mismatch needs the approved
24
+ runtime contract, not repeated package versions. Unknown request keys return 422; do not add `runtime`, `image`, or `resources`
25
+ fields. Inspect the returned resolved package.
26
+
27
+ `input_modes` must be unique, include `inline`, and may additionally include
28
+ `feature_lookup` or `tabular_forecast` only when supported by the selected
29
+ runtime. `feature_lookup` still requires artifact lineage
30
+ `online_eligible=true`; `tabular_forecast` requires a direct tabular model
31
+ signature. Do not infer either capability from training success.
32
+ Omit rather than use an empty list to request default inline behavior.
33
+
34
+ Always query the exact package ID and version; states are `PACKAGING`, `READY`,
35
+ `FAILED`, `CANCELLED`. A client timeout does not prove packaging failed. Retain the
36
+ known identity and query it before attempting another creation.
37
+
38
+ ```bash
39
+ ml-platform --profile server validate-model-artifact <artifact-id>
40
+ ml-platform --profile server validate-model-package model-package-request.json
41
+ ml-platform --profile server create-model-package model-package-request.json
42
+ ml-platform --profile server get-model-package <package-id> --package-version <version>
43
+ ```
44
+
45
+ Confirm the ModelArtifact, signature, runtime, immutable base/builder/worker image digests, input modes, semantic package version, and destination repository. Creation submits a workload and needs separate authorization. Never put registry credentials in JSON.
46
+
47
+ A deliverable package is `READY` and includes its remote image digest, immutable reference, manifest, signature and adapter hashes, runtime capabilities, and a passing test report for the same digest. Other states are not deliverable.
48
+
49
+ For a sequence-output artifact, inspect the returned runtime contract for
50
+ `output_schema.kind=sequence`, its fixed maximum `length` and frequency, and
51
+ `horizon_prediction=prefix`. Inference returns the requested aligned prefix up
52
+ to that maximum; a one-step artifact remains scalar.
53
+
54
+ ```bash
55
+ ml-platform --profile server cancel-model-package <package-id> --package-version <version>
56
+ ```
57
+
58
+ Cancellation requires exact-package authorization. Do not rebuild an immutable failed version; correct inputs and create a new semantic package version. This Skill does not deploy images or write model-center delivery status.
@@ -0,0 +1,259 @@
1
+ # Training request and response contracts
2
+
3
+ These examples require only the released CLI, inspected registry definitions and
4
+ downloaded dataset contracts. Replace example identities and business choices;
5
+ they are not a ready-to-submit trainer recommendation. Never import platform
6
+ Python modules or require a checkout to author these requests.
7
+
8
+ ## TrainingRunSpec
9
+
10
+ Example forecasting sequence run:
11
+
12
+ ```json
13
+ {
14
+ "schema_version": "ml_data_platform.training_run/v3",
15
+ "run_id": "pressure_forecast_run_01",
16
+ "experiment": "pressure_forecast",
17
+ "task": {"kind": "forecasting", "objective": "regression"},
18
+ "data": {
19
+ "artifact": {
20
+ "project": "default", "dataset_id": "pressure_dataset",
21
+ "manifest_hash": "REPLACE_WITH_RETURNED_MANIFEST_HASH"
22
+ },
23
+ "features": {"feature_set": {
24
+ "project": "default", "name": "pressure_features", "version": "v1"
25
+ }},
26
+ "labels": ["future_pressure"],
27
+ "temporal": {
28
+ "prediction_time_column": "event_time", "label_time_column": "label_time",
29
+ "frequency": "5min", "horizon": "5min", "series_keys": []
30
+ },
31
+ "splits": {
32
+ "assignment_column": "rowset_split", "train": ["training"],
33
+ "validation": ["validation"], "test": ["test"]
34
+ }
35
+ },
36
+ "input_adapter": {
37
+ "kind": "sequence", "context_length": 24,
38
+ "context_end": "prediction_time_inclusive", "frequency": "5min",
39
+ "stride": 1, "gap_policy": "reject", "padding_policy": "none"
40
+ },
41
+ "forecast_target_adapter": {
42
+ "schema_version": "ml_data_platform.forecast_target_adapter/v1",
43
+ "kind": "continuous_target_series",
44
+ "target_input_column": "pressure",
45
+ "output_label_column": "future_pressure",
46
+ "target_gap_policy": "reject",
47
+ "point_output": {"statistic": "median", "step": "horizon"}
48
+ },
49
+ "label_transform": {"name": "identity", "version": "v1"},
50
+ "trainer": {
51
+ "project": "default", "name": "replace_approved_trainer", "version": "v1",
52
+ "parameters": {}
53
+ },
54
+ "reproducibility": {"seed": 0, "deterministic": true},
55
+ "evaluation": {"split": "validation", "metrics": ["mae", "rmse", "r2"]}
56
+ }
57
+ ```
58
+
59
+ `task.kind`, objective and input kind must match inspected TrainerCapabilities.
60
+ `trainer.parameters` must satisfy the definition's parameter schema; `{}` only
61
+ works if no parameters are required. Resource/device settings belong to the Job,
62
+ not the Run. `run_id` is the immutable run identity, not a name/version pair.
63
+ Do not add guessed `version`, `model`, `dataset` or `hyperparameters` top-level keys.
64
+
65
+ For tabular input use `input_adapter: {"kind":"tabular"}`; omit sequence context
66
+ fields. Forecasting tasks still require `data.temporal`, even with tabular input.
67
+ Non-temporal regression can omit it. Do not change task kind just to evade checks.
68
+ `series_keys` must identify entity-key columns when multiple series coexist;
69
+ an empty list treats the entire artifact as one series.
70
+
71
+ ## Direct tabular forecasting with known-future features
72
+
73
+ Tree and other matrix-based models can forecast a variable target grid without
74
+ pretending that future observations are available. Set the tabular adapter to
75
+ `forecast_mode="direct"`. The dataset's `TemporalBinding.prediction_time_column`
76
+ is the historical `cutoff_time`; `label_time_column` is the row's future
77
+ `target_time`. Each row is one `(cutoff_time, target_time)` pair. Values such as
78
+ weather forecasts, schedules, calendar fields and `lead_hours` are ordinary
79
+ feature columns; list the forecast columns in `known_future_columns`.
80
+
81
+ ```json
82
+ {
83
+ "input_adapter": {
84
+ "kind": "tabular",
85
+ "forecast_mode": "direct",
86
+ "known_future_columns": ["weather_temperature", "weather_wind"]
87
+ },
88
+ "data": {
89
+ "temporal": {
90
+ "prediction_time_column": "cutoff_time",
91
+ "label_time_column": "target_time",
92
+ "frequency": "1h",
93
+ "horizon": "240h",
94
+ "series_keys": ["market"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ At serving time use `input_mode="tabular_forecast"` and send one row per
101
+ target. `target_time` must be later than the cutoff and aligned to the model
102
+ frequency. When known-future columns are declared, every row must include
103
+ `available_at <= cutoff_time`; this prevents using a forecast revision that did
104
+ not exist when the prediction was made.
105
+
106
+ ```json
107
+ {
108
+ "input_mode": "tabular_forecast",
109
+ "cutoff_time": "2026-09-09T10:30:00+08:00",
110
+ "targets": [
111
+ {
112
+ "target_time": "2026-09-10T00:00:00+08:00",
113
+ "available_at": "2026-09-09T08:00:00+08:00",
114
+ "values": {
115
+ "weather_temperature": 21.3,
116
+ "weather_wind": 2.8,
117
+ "lead_hours": 13.5
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ ```
123
+
124
+ The serving runtime calls the same plugin `predict()` with a two-dimensional
125
+ batch and returns one result carrying each `target_time`. XGBoost and LightGBM
126
+ already implement this batch matrix operation; the platform adapter owns the
127
+ cutoff, target-grid and availability checks. Training must use historical
128
+ forecast snapshots selected by `available_at <= cutoff_time`, never later actual
129
+ weather observations.
130
+
131
+ Inspect `data_schema.json`, `resolved_manifest.json` and the feature Parquet via
132
+ `download-dataset-artifact DATASET_ID MANIFEST_HASH --project PROJECT --out-dir DIR`
133
+ (repeat `--file` for selective downloads). The FeatureSet reference must match
134
+ the artifact; the full ordered FeatureSet determines model channels. There is
135
+ no documented `data.features.columns` shortcut for choosing a subset.
136
+
137
+ `identity:v1` leaves labels unchanged. `difference` requires a baseline Feature
138
+ in `required_inputs` and at least one `online_inputs` entry, which must be a
139
+ subset; it must have an inverse. Do not use target transforms to fix incorrect
140
+ dataset label clocks or to invent unsupported transforms.
141
+
142
+ ## Chronos-2 v2 targets and covariates
143
+
144
+ Use the v2 adapter when Chronos-2 should jointly forecast multiple storage
145
+ channels or consume covariates. The target and output-label arrays are ordered,
146
+ and `data.labels` must use that same output-label order:
147
+
148
+ ```json
149
+ {
150
+ "labels": ["future_storage_soc", "future_storage_power"],
151
+ "forecast_target_adapter": {
152
+ "schema_version": "ml_data_platform.forecast_target_adapter/v2",
153
+ "kind": "continuous_target_series_with_covariates",
154
+ "targets": [
155
+ {"input_column": "storage_soc", "output_label_column": "future_storage_soc"},
156
+ {"input_column": "storage_power", "output_label_column": "future_storage_power"}
157
+ ],
158
+ "covariates": [
159
+ {"column": "recent_load", "role": "past_only"},
160
+ {"column": "weather_temperature", "role": "known_future"},
161
+ {"column": "peak_valley", "role": "known_future"}
162
+ ],
163
+ "target_gap_policy": "reject",
164
+ "point_output": {"statistic": "median", "step": "horizon"}
165
+ }
166
+ }
167
+ ```
168
+
169
+ Every target and covariate must be a numeric Feature. `past_only` is available
170
+ only through the cutoff. `known_future` must be represented in training by the
171
+ forecast or schedule available at that historic cutoff, never by a later actual
172
+ observation. At runtime callers provide one finite numeric value for every
173
+ `known_future` column and every prediction step. The current contract validates
174
+ the names, values, and row count; retain forecast issue/availability lineage in
175
+ the upstream Feature data when revisions must be audited.
176
+
177
+ ## TrainingJobRequest and identity propagation
178
+
179
+ After validation and authorized registration, use the returned `spec_hash`
180
+ unchanged in the Job request. Do not calculate it from raw JSON bytes.
181
+
182
+ ```json
183
+ {
184
+ "run": {
185
+ "run_id": "pressure_forecast_run_01",
186
+ "spec_hash": "REPLACE_WITH_REGISTERED_SPEC_HASH"
187
+ },
188
+ "execution": {
189
+ "executor": "kubernetes", "device": "cpu",
190
+ "resources": {"cpu": "2", "memory": "4Gi"},
191
+ "deadline": "90min", "retry_limit": 0
192
+ }
193
+ }
194
+ ```
195
+
196
+ Sizing is illustrative. `spec_hash` uses `sha256:<64 hex>`. Omit `output_uri`
197
+ to use managed storage unless an approved contract supplies it. Runtime device
198
+ approval occurs during Job resolution; `validate-training-run` has no execution
199
+ device and cannot prove device approval. Use `validate-training-job` after Run registration to validate device and
200
+ execution settings without creating a Job.
201
+
202
+ | Command | Fields to retain / inspect |
203
+ | --- | --- |
204
+ | `validate-training-run` | `status=valid`, `spec_hash`, `data_schema_hash`, `feature_columns`, `label_columns` |
205
+ | `register-training-run` | `training_run.run_id`, top-level `spec_hash`; response `status=validated` also represents registration, not mere dry-run |
206
+ | `submit-training-job` | `job_spec.job_id`, `job_spec.job_spec_hash`, `job.phase`; top-level `status=accepted` is not completion |
207
+ | `get-training-job` | `spec` and `status`; inspect `status.phase`, then successful `status.artifact_id` |
208
+ | `validate-model-artifact` | Validation evidence for the exact returned artifact ID; Job success alone is insufficient |
209
+
210
+ Use `get-training-run`, `get-model-artifact` and their list commands to recover
211
+ identities; see [discovery.md](discovery.md). There is no training wait command.
212
+ Preserve the original Run JSON and IDs.
213
+ Poll `get-training-job` at a bounded interval (for example 15 seconds) with a
214
+ user-appropriate deadline; a polling timeout does not cancel or fail the Job.
215
+ After a submission timeout, retain the request and reconcile any known Job ID
216
+ before retrying. Never create a new run merely because the HTTP response was lost.
217
+
218
+ ## Sequence population semantics
219
+
220
+ Context step is `frequency * stride`. Stride spaces context observations; it
221
+ does not select every Nth target endpoint. Inclusive context with length L covers
222
+ offsets `(L-1)..0`; exclusive covers `L..1`. For 24 points, 5min frequency and
223
+ stride 1, inclusive context starts 115min before the cutoff, exclusive 120min.
224
+ Keep Operator source history and endpoint-policy lookback as separate contracts.
225
+
226
+ The adapter materializes history over the full series, then assigns samples by
227
+ the target endpoint's split. Test endpoints may use causal Feature history from
228
+ earlier splits; splitting does not truncate their context. Duplicate timestamps
229
+ within a series are invalid. Missing early context with no padding is skipped;
230
+ null Features or labels also skip samples. Candidate row counts therefore are
231
+ not training/evaluation sample counts. Report the materialized population and
232
+ coverage instead of assuming all Parquet rows were used.
233
+
234
+ For `continuous_target_series`, TrainingRun v3 derives the fixed maximum
235
+ `prediction_length` as `data.temporal.horizon / data.temporal.frequency`; the
236
+ horizon must be a positive exact multiple of the frequency. The target input
237
+ must be a numeric, at-prediction Feature and the output label must be the sole
238
+ entry in `data.labels`. Use this adapter only when the inspected TrainerDefinition
239
+ advertises `forecast_target_modes=["continuous_target_series"]`.
240
+
241
+ The resulting model emits the complete fixed-length trajectory. Serving accepts
242
+ aligned horizons up to that maximum and returns the corresponding trajectory
243
+ prefix; it rejects unaligned or longer horizons. A one-step model remains a
244
+ scalar response.
245
+
246
+ `gap_policy=fill` requires `padding_policy=edge` or `zero`; non-fill requires
247
+ `padding_policy=none`. Filling changes model inputs and needs an intended
248
+ business policy. `skip` and padding are not automatic fixes for rejected grids.
249
+
250
+ Training's `evaluation.metrics` uses `mae`, `rmse`, `r2`. Independent governed
251
+ EvaluationConfig uses versioned names such as `regression.mae`. They are different
252
+ contracts. Training `evaluation.split=auto` prefers nonempty test, then validation,
253
+ then train; choose an explicit split when reserving the test set for final review.
254
+ Training metrics are not a governed EvaluationResult or release gate pass.
255
+
256
+ For sequence outputs, current training and governed evaluation apply regression
257
+ metrics to the terminal point at the trained maximum horizon. They do not yet
258
+ provide per-step or whole-trajectory release gates; record this limitation when
259
+ reporting evidence for a multi-point package.
@@ -0,0 +1,107 @@
1
+ # Training Commands
2
+
3
+ ## Preflight before expensive training
4
+
5
+ Settle the final DataSchema (including split/metadata and label/time columns),
6
+ FeatureSet order and evaluation runtime before the first Job. See
7
+ [evaluation.md](evaluation.md) for inherited split bindings and runtime failures.
8
+
9
+ - Inspect exact TrainerDefinition `project/name:v1`, entrypoint, image digest,
10
+ capabilities (including `forecast_target_modes`) and parameter schema. Similar names in different projects are
11
+ distinct identities; registration does not imply runtime approval.
12
+ - Match definition and device to the active runtime release. On `not approved
13
+ for device`, preserve the rejected identity, device and release ID. Use `get-model-runtime-release` to find the
14
+ approved binding; if the deployed release lacks discovery, request its contract;
15
+ do not try similar names or re-register trainers to bypass approval.
16
+ - Chronos-2 supports the legacy v1 single-target adapter and the v2
17
+ covariate-aware adapter. v2 jointly forecasts ordered target channels and
18
+ accepts numeric `past_only` and `known_future` covariates. Do not silently
19
+ drop business inputs: declare every target and covariate in the adapter.
20
+ - Keep labels outside FeatureSet order, verify temporal horizon against
21
+ `label_time - prediction_time`, and validate the complete TrainingRun before
22
+ registration/submission. Validation may not catch undeclared plugin limits or
23
+ missing dependencies in the eventual Worker.
24
+ - For a continuous future trajectory, use TrainingRun v3. Use
25
+ `continuous_target_series` for legacy v1 or
26
+ `continuous_target_series_with_covariates` for v2. Its fixed maximum
27
+ prediction length comes from temporal horizon divided by frequency; do not
28
+ put `prediction_length` in trainer-specific parameters.
29
+
30
+ Merge this fragment under TrainingRun `data`, alongside `artifact`, `features`,
31
+ `labels` and the applicable `temporal` binding:
32
+
33
+ ```json
34
+ {
35
+ "splits": {
36
+ "assignment_column": "rowset_split",
37
+ "train": ["training"],
38
+ "validation": ["validation"],
39
+ "test": ["test"]
40
+ }
41
+ }
42
+ ```
43
+
44
+ `train` is the consumer role; `training` is an example observed artifact value.
45
+ Use the actual assignment values. Evaluation inherits this original binding;
46
+ it does not reconstruct it from manifest `rowset_splits`. Save the submitted
47
+ TrainingRun JSON, validation output, Job ID and ModelArtifact ID in the user's
48
+ working directory so later diagnosis needs no source repository.
49
+
50
+ ## Commands
51
+
52
+ Read [training-contracts.md](training-contracts.md) when authoring a Run or Job
53
+ JSON. It provides complete request shapes, response paths and sequence semantics.
54
+
55
+ Discover already-registered TrainerDefinitions (read-only) before authoring a
56
+ TrainingRunSpec or deciding whether registration is needed:
57
+
58
+ ```bash
59
+ ml-platform --profile server list-trainer-definitions
60
+ ml-platform --profile server get-trainer-definition <name> <version> [--project default]
61
+ ```
62
+
63
+ `get-trainer-definition` returns the entrypoint, immutable training image digest,
64
+ `artifact_format`, `model_file`, capabilities, and parameter schema. Use it to confirm
65
+ the referenced `v1` definition exists and its image digest matches the approved runtime
66
+ release; discovery never mutates the registry. Registering a new definition is the
67
+ separate mutation below, and a 404 means the definition (not the model plugin) is missing.
68
+
69
+ ```bash
70
+ ml-platform --profile server register-trainer trainer-definition.json
71
+ ml-platform --profile server validate-training-run training-run.json
72
+ ml-platform --profile server register-training-run training-run.json
73
+ ml-platform --profile server validate-training-job training-job-request.json
74
+ ml-platform --profile server submit-training-job training-job-request.json
75
+ ml-platform --profile server get-training-job <job-id>
76
+ ```
77
+
78
+ The TrainingRun binds immutable DatasetArtifact identities, DataSchema, ordered inputs, targets, InputAdapter, TrainerDefinition `v1`, reproducibility controls, and runtime identity. Validation proves compatibility only. Submit the run and Job separately after authorization and record spec hash and Job ID. Terminal success must expose a ModelArtifact ID; validate it before evaluation or packaging.
79
+
80
+ ```bash
81
+ ml-platform --profile server validate-model-artifact <artifact-id>
82
+ ml-platform --profile server retry-training-job <job-id>
83
+ ml-platform --profile server cancel-training-job <job-id>
84
+ ```
85
+
86
+ Retry and cancellation require exact-Job authorization. Never change a run contract while retrying; create a new immutable run when semantic inputs change.
87
+
88
+ ## Chronos-2 future-known inputs
89
+
90
+ For storage forecasting, tomorrow's weather forecast and peak/valley schedule
91
+ are `known_future` covariates. The v2 adapter binds their Feature columns and
92
+ the ordered target/output-label pairs; see [training-contracts.md](training-contracts.md)
93
+ for the complete JSON fragment.
94
+
95
+ Training records must contain the forecast that was available at each historic
96
+ cutoff, not actual weather observed later. At online inference, pass one numeric
97
+ row per forecast step using the Serving runtime, not `fetch-inference-data`:
98
+
99
+ ```bash
100
+ ml-platform predict-model /absolute/path/to/inference-request.json \
101
+ --serving-url https://storage-forecast.example
102
+ ```
103
+
104
+ For `input_mode=inline`, put those rows in `inputs.future_covariates`. For
105
+ `input_mode=feature_lookup`, put them in the top-level `future_covariates`.
106
+ Their column names must exactly match the adapter's `known_future` covariates,
107
+ and their count must equal the trained `prediction_length`.