@zhuoyuezs/ml-platform 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/DEVELOPMENT.md +189 -0
  2. package/README.md +103 -0
  3. package/checksums.json +110 -0
  4. package/package.json +29 -0
  5. package/release-policy.json +31 -0
  6. package/release.json +42 -0
  7. package/runtime/business-client/README.md +14 -0
  8. package/runtime/business-client/package-lock.json +19 -0
  9. package/runtime/business-client/package.json +21 -0
  10. package/runtime/business-client/src/catalog.js +184 -0
  11. package/runtime/business-client/src/cli.js +225 -0
  12. package/runtime/business-client/src/config.js +52 -0
  13. package/runtime/business-client/src/http.js +137 -0
  14. package/scripts/lib.js +819 -0
  15. package/scripts/main.js +92 -0
  16. package/skills/feature-management/SKILL.md +265 -0
  17. package/skills/feature-management/agents/openai.yaml +4 -0
  18. package/skills/feature-management/assets/catalog-template/catalog.json +23 -0
  19. package/skills/feature-management/assets/catalog-template/datasets/example_temperature_training.v1.json +24 -0
  20. package/skills/feature-management/assets/catalog-template/feature_sets/example_temperature_core.v1.json +13 -0
  21. package/skills/feature-management/assets/catalog-template/features/example_temperature_mean_5m.v1.json +21 -0
  22. package/skills/feature-management/assets/catalog-template/operator_package/pyproject.toml +12 -0
  23. package/skills/feature-management/assets/catalog-template/operator_package/src/business_feature_operator_template/__init__.py +39 -0
  24. package/skills/feature-management/assets/catalog-template/operator_package/tests/test_operator.py +56 -0
  25. package/skills/feature-management/assets/catalog-template/operators/example_temperature_features.v1.json +43 -0
  26. package/skills/feature-management/assets/catalog-template/parameters/example_temperature.v1.json +57 -0
  27. package/skills/feature-management/references/commands.md +244 -0
  28. package/skills/feature-management/references/contracts.md +682 -0
  29. package/skills/feature-management/references/operator-authoring.md +167 -0
@@ -0,0 +1,167 @@
1
+ # Operator Authoring
2
+
3
+ Read this file whenever a workflow creates or changes executable Operator code.
4
+
5
+ ## Contents
6
+
7
+ 1. Package contract
8
+ 2. Feature entrypoint contract
9
+ 3. Causal calculation rules
10
+ 4. Required tests
11
+ 5. Build and publication
12
+ 6. Security boundary
13
+
14
+ ## Package Contract
15
+
16
+ Build a standalone pure-Python wheel. Do not import report-local, experiment-local, or unregistered business packages. Declare runtime dependencies explicitly, but keep the package small and compatible with `py3-none-any`.
17
+
18
+ Minimal `pyproject.toml`:
19
+
20
+ ```toml
21
+ [build-system]
22
+ requires = ["hatchling"]
23
+ build-backend = "hatchling.build"
24
+
25
+ [project]
26
+ name = "pressure-features"
27
+ version = "1.0.0"
28
+ requires-python = ">=3.10"
29
+ dependencies = ["pandas>=2.3.3"]
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ packages = ["src/pressure_features"]
33
+ ```
34
+
35
+ Keep package version and Operator Registry version independently explicit. Change both when code behavior changes unless a documented release policy maps them differently.
36
+
37
+ ## Feature Entrypoint Contract
38
+
39
+ Implement:
40
+
41
+ ```python
42
+ def compute_features(context: Any) -> pandas.DataFrame:
43
+ ...
44
+ ```
45
+
46
+ Available context fields:
47
+
48
+ ```text
49
+ manifest
50
+ features
51
+ inputs
52
+ config
53
+ requested_output_columns
54
+ operator
55
+ parameters
56
+ metric_frames
57
+ target_times
58
+ prediction_horizon
59
+ cutoff_times
60
+ furnace_id
61
+ computation_hash
62
+ ```
63
+
64
+ Each `metric_frames[parameter_key]` is a standard long frame with source timestamps and values. Resolve frames from `context.inputs`; do not reach into a database, API, filesystem secret, or environment credential.
65
+
66
+ Use `context.cutoff_times` for causal feature windows. It is derived once from
67
+ `context.target_times - context.prediction_horizon` using the DatasetManifest
68
+ prediction contract; do not parse a duplicated Feature-level horizon.
69
+
70
+ If an Operator requires a forecast contract, declare `input_schema.prediction`
71
+ with `required`, `minimum_horizon`, and `maximum_horizon`. Declare source history
72
+ as `input_schema.history_requirements`, using `anchor: cutoff` for causal windows
73
+ and `anchor: target_time` only for intentional target-aligned formulas. Scope a
74
+ requirement with `output_columns` when only some outputs need it. Include alignment
75
+ slack such as hourly floor boundaries in the declared lookback.
76
+
77
+ For realtime reads, `history_requirements` is also the per-Parameter fetch
78
+ contract. Do not rely on a package-local lookback map or a single fixed window
79
+ shared by all inputs. The realtime runner widens a half-open adapter read by one
80
+ grid step, then applies `timestamp <= cutoff`; an Operator must never consume a
81
+ post-cutoff row.
82
+
83
+ Return requirements:
84
+
85
+ - Return a pandas DataFrame.
86
+ - Return exactly one row per `context.target_times` entry.
87
+ - Return `event_time` in the same order and with the same timestamps.
88
+ - Optionally return `furnace_id`.
89
+ - Return every requested physical output column.
90
+ - Avoid calculating unrequested expensive columns when practical.
91
+ - Reject unknown requested output columns.
92
+ - Preserve numeric missing values rather than silently filling them without a declared rule.
93
+
94
+ One Operator may return multiple physical columns. Each public Feature still binds one `output_column` and exact inputs.
95
+
96
+ ## Causal Calculation Rules
97
+
98
+ State every time rule in tests and descriptions:
99
+
100
+ - forecast horizon and cutoff derivation;
101
+ - whether an event exactly at cutoff is included (`<=`) or excluded (`<`);
102
+ - rolling window left/right closure;
103
+ - timezone and daylight-saving assumptions;
104
+ - duplicate timestamp resolution;
105
+ - sparse-event fallback behavior;
106
+ - rounding stage and decimal count;
107
+ - behavior before and after dated business-rule changes.
108
+
109
+ Never infer a rule from a Feature name alone. Require a business decision when a boundary is unspecified.
110
+
111
+ ## Required Tests
112
+
113
+ Use deterministic fixtures and cover:
114
+
115
+ 1. expected formula values;
116
+ 2. the event immediately before cutoff;
117
+ 3. an event exactly at cutoff;
118
+ 4. an event immediately after cutoff;
119
+ 5. missing and duplicate inputs;
120
+ 6. empty history or insufficient lookback;
121
+ 7. requested output subsets;
122
+ 8. exact `event_time` row count and order;
123
+ 9. output dtype and rounding;
124
+ 10. every dated business-rule branch.
125
+
126
+ Run package tests before building the wheel. Then inspect the wheel tag and ensure it is `py3-none-any`.
127
+
128
+ ## Build And Publication
129
+
130
+ Build into the catalog path referenced by `catalog.json`:
131
+
132
+ ```bash
133
+ uv build <catalog>/operator_package \
134
+ --wheel \
135
+ --out-dir <catalog>/operator_package/dist
136
+ ```
137
+
138
+ Keep the draft Operator fields null:
139
+
140
+ ```json
141
+ {
142
+ "code_hash": null,
143
+ "package_uri": null,
144
+ "code_artifact": null
145
+ }
146
+ ```
147
+
148
+ Catalog publication uploads the wheel, computes SHA-256 and size, records its immutable object URI, and registers the resolved OperatorSpec.
149
+
150
+ Do not reuse an Operator version with a different wheel. If the same key already exists with different content or digest, create a new version.
151
+
152
+ ## Security Boundary
153
+
154
+ The current runtime blocks socket networking, removes storage/source credentials from the child environment, verifies the wheel hash, enforces a timeout, and extracts only pure-Python wheels without native libraries or unsafe paths.
155
+
156
+ This is not a complete OS sandbox. Therefore:
157
+
158
+ - publish only reviewed internal code;
159
+ - do not read arbitrary host paths;
160
+ - do not spawn subprocesses;
161
+ - do not access secrets or environment configuration;
162
+ - do not use dynamic code evaluation;
163
+ - do not add native libraries;
164
+ - do not perform network calls;
165
+ - keep resource limits conservative.
166
+
167
+ Request an engineering/security review when the formula requires capabilities outside this boundary.